-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hi! 👋
I'm having issue building the sph2pipe on Mac OS Sonoma and Xcode 15. Here are the errors:
cc -o sph2pipe -s -w -g -O2 file_headers.c shorten_x.c sph2pipe.c -lm
file_headers.c:100:17: error: call to undeclared library function 'strdup' with type 'char *(const char *)'; ISO C99 and later do not support i
mplicit function declarations [-Wimplicit-function-declaration]
inporder = strdup( fldsval );
^
file_headers.c:100:17: note: include the header <string.h> or explicitly provide a declaration for 'strdup'
1 error generated.
sph2pipe.c:213:16: error: call to undeclared library function 'strdup' with type 'char *(const char *)'; ISO C99 and later do not support impli
cit function declarations [-Wimplicit-function-declaration]
hdrfile = strdup( optarg );
^
Here's similar issue in other project. They fixed it by defining _DARWIN_C_SOURCE. Like this:
file_headers.c:
#define _XOPEN_SOURCE 500 /* See feature_test_macros(7) */
#define _DARWIN_C_SOURCE
#include <math.h>
#include <string.h>
#include <unistd.h>
/* code goes on ... */sph2pipe.c:
#define _SPH_CONVERT_MAIN_
#define _XOPEN_SOURCE 500 /* See feature_test_macros(7) */
#define _DARWIN_C_SOURCE
#include <string.h>
#include <unistd.h>
/* code goes on ... */I might send PR if you are interested in fixing it. I'm not very proficient in C code and don't know if those changes could break anything, but I can confirm that the changes are working. After adding those headers code builds just fine.
Thanks!
wuhongsheng
Metadata
Metadata
Assignees
Labels
No labels