_POSIX_C_SOURCE breaks build on MacOS X
This came in via github: https://github.com/UpstandingHackers/hammer/issues/197
hammer fails to build on Mac OS Catalina 10.15.3.
build/opt/src/platform_bsdlike.c:33:10: error: implicit declaration of function 'vasprintf' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
We're not seeing vasprint() because we're calling clang with -D_POSIX_C_SOURCE=200809L. [...] stdio.h defines vasprint at line 377, which requires __DARWIN_C-LEVEL >= __DARWIN_C_FULL. These, in turn, are defined in ...sys/cdefs.h [...], which specifies __DARWIN_C_FULL (only) if neither __DARWIN_C_ANSI nor _POSIX_C_SOURCE has been defined.
I have tracked down the origin of that define in our compiler flags to commit 321600b6 where
it was lifted out of src/registry.c
and replaced with #include <search.h>
. That include
must be for the tsearch() family of functions which are indeed POSIX functions.
However, registry.c
already includes src/tsearch.h
which appears to be a platform-independent
wrapper for that header.
So AFAICT, the right way to do all this is to define _POSIX_C_SOURCE
in the POSIX path
of tsearch.h
, remove the extraneous #include
of search.h
in registry.c
and drop the
define from the global CFLAGS.
ACK?