New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strnlen Compilation problem [COMPILE,CLANG] #22443

Open
MagicToster opened this Issue Nov 18, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@MagicToster

MagicToster commented Nov 18, 2017

Game version:"0.C-25055-gb94c476f73-dirty"

Operating system:FreeBSD 11.0-RELEASE-p12

It's compilation problem with filesystem.cpp and #include <string.h> ( I think ), I use FreeBSD clang version 3.8.0. I don't know what exactly is wrong but when try to gmake, I got

src/filesystem.cpp:215:28: error: use of undeclared identifier 'strnlen'
auto const len_fname = strnlen(entry.d_name, sizeof_array(entry.d_name));
^
I check if <string.h> even work on my Os, and it work. Anyone know what is wrong ?

@kevingranade

This comment has been minimized.

Show comment
Hide comment
@kevingranade

kevingranade Nov 19, 2017

Member

Historically, the freebsd developers have had a bug up their collective asses about strnlen.
http://freebsd-hackers.freebsd.narkive.com/qORUKIgr/where-is-strnlen
I can't find the current state of things, but it's possible that freebsd does not include it by default and requires an extra flag or something.

I also note that it is not officially a part of the c++ standard, so that exclusion is technically correct.

Solutions:

  • Add a BSD-specific build flag here:
    #if (defined __MINGW32__ || defined __CYGWIN__)
    to define it locally on bsd.
  • This is the only place it is used in our codebase, so perhaps we should just:
    • refactor the code to make it unecessary.
    • if it's really necessary here, just inline the definition in the one place it is used.
Member

kevingranade commented Nov 19, 2017

Historically, the freebsd developers have had a bug up their collective asses about strnlen.
http://freebsd-hackers.freebsd.narkive.com/qORUKIgr/where-is-strnlen
I can't find the current state of things, but it's possible that freebsd does not include it by default and requires an extra flag or something.

I also note that it is not officially a part of the c++ standard, so that exclusion is technically correct.

Solutions:

  • Add a BSD-specific build flag here:
    #if (defined __MINGW32__ || defined __CYGWIN__)
    to define it locally on bsd.
  • This is the only place it is used in our codebase, so perhaps we should just:
    • refactor the code to make it unecessary.
    • if it's really necessary here, just inline the definition in the one place it is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment