-
Notifications
You must be signed in to change notification settings - Fork 208
Description
json2cbor.c doesn't compile on macOS/BSD libc with the following error:
tools/json2cbor/json2cbor.c:201:9: error: implicit declaration of function 'asprintf' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (asprintf(&metadatakey, "%s%s", item->string, meta_data_marker) < 0 || metadatakey == NULL)
^
1 error generated.tinycbor/tools/json2cbor/json2cbor.c
Line 201 in 0a488a5
| if (asprintf(&metadatakey, "%s%s", item->string, meta_data_marker) < 0 || metadatakey == NULL) |
This happens because it defines #define _POSIX_C_SOURCE 200809L, which on some libcs, like macOS's and BSD's (I didn't test BSD, but I've seen similar issues saying the same thing), causes any non-POSIX functionality to not be declared. Thus, when #define _GNU_SOURCE is defined, which normally defines GNU extensions like asprintf, it is superseded by the #define _POSIX_C_SOURCE 200809L.
tinycbor/tools/json2cbor/json2cbor.c
Lines 25 to 26 in 0a488a5
| #define _POSIX_C_SOURCE 200809L | |
| #define _GNU_SOURCE |
Is the #define _POSIX_C_SOURCE 200809L needed? Without that define, I was able to compile everything. If it's not needed, I can submit a PR to remove it so it compiles on macOS and BSDs.