`_XOPEN_SOURCE` define in `src/misc.c` seems extraneous
NattyNarwhal opened this issue · 0 comments
NattyNarwhal commented
On macOS, if that #define
is present, you get a fun error:
/Users/calvin/src/createrepo_c/src/misc.c:1664:5: error: call to undeclared library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
snprintf(dict_file, strlen(file) + 7, "%s.zdict", file);
^
/Users/calvin/src/createrepo_c/src/misc.c:1664:5: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
...even though stdio.h
is included. If this is really needed on Linux, it should be set on a per-platform and/or per-file level by CMake, not inline.
Fix patch:
diff --git a/src/misc.c b/src/misc.c
index 8511ca2..488e898 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -17,8 +17,6 @@
* USA.
*/
-#define _XOPEN_SOURCE 500
-
#include <glib/gstdio.h>
#include <glib.h>
#include <gio/gio.h>