feh
feh copied to clipboard
Implicit function declarations
Building feh-3.4 on OS X 10.13, I get a bunch of warnings:
getopt.c:539:26: warning: implicitly declaring library function 'strcmp' with type 'int (const char *, const char *)' [-Wimplicit-function-declaration]
if (optind != argc && !strcmp(argv[optind], "--")) {
^
getopt.c:539:26: note: include the header <string.h> or explicitly provide a declaration for 'strcmp'
getopt.c:610:9: warning: implicitly declaring library function 'strncmp' with type 'int (const char *, const char *, unsigned long)' [-Wimplicit-function-declaration]
if (!strncmp(p->name, nextchar, nameend - nextchar)) {
^
getopt.c:610:9: note: include the header <string.h> or explicitly provide a declaration for 'strncmp'
getopt.c:611:63: warning: implicitly declaring library function 'strlen' with type 'unsigned long (const char *)' [-Wimplicit-function-declaration]
if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen(p->name)) {
^
getopt.c:611:63: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
and
imlib.c:579:7: warning: implicit declaration of function 'mkdtemp' is invalid in C99 [-Wimplicit-function-declaration]
if (mkdtemp(tempdir) == NULL) {
^
imlib.c:579:24: warning: comparison between pointer and integer ('int' and 'void *')
if (mkdtemp(tempdir) == NULL) {
~~~~~~~~~~~~~~~~ ^ ~~~~
My platform has getopt in its system libs, so I don't know why feh is building its own at all, but anyway, these warnings all seem like they can be cured by adding some #include to the .c files.
The issue for imlib.c is that Apple's unistd.h has some #ifdef spaghetti wrapping the mkdtemp() prototype and the default CFLAGS don't get it. Adding -D_DARWIN_C_SOURCE fixes it, but obviously that's not portable to non-darwin platforms.