Collin Funk wrote: > If you look in <unistd.h> you will see something like the following: > > #if defined _XPG4_2 > extern extern int gethostname (char *name, size_t len); > #else > extern extern int gethostname (char *name, int len); > #endif > > Something similar happens for accept with socklen_t * as the third > argument instead of void * when _XPG4_2 is defined. And so on for the > other functions. > > The _XPG4_2 macro is an internal macro that gets defined in > /usr/include/sys/feature_tests.h. There is more commentary in that file > but here should be the most important parts: > > > * Feature Test Macro Specification > * ------------------------------------------------ ------------- > * _XOPEN_SOURCE XPG3 > * _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4 > * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2 > * _XOPEN_SOURCE = 500 XPG5 > * _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6 > * _XOPEN_SOURCE = 700 (or POSIX_C_SOURCE=200809L) XPG7 > * _XOPEN_SOURCE = 800 (or POSIX_C_SOURCE=202405L) XPG8
This is like in Solaris OpenIndiana, where - for best results - I recommend to use -D_XOPEN_SOURCE=700 [1]. > I was thinking maybe a check should be added to m4/extensions.m4 (or the > upstream version in Autoconf?). What do you think about this? It's a tricky business, because it depends on the package whether 600, 700, or 800 is the best value. For this reason, m4/extensions.m4 has a comment: /* Enable X/Open extensions. Define to 500 only if necessary to make mbstate_t available. */ #ifndef _XOPEN_SOURCE # undef _XOPEN_SOURCE #endif Therefore, although we know that _generally_ _XOPEN_SOURCE = 700 or 800 may be useful, it's too risky to enable in Autoconf and Gnulib. And the CI should test what Gnulib provides, with the minimum of extra CFLAGS or CPPFLAGS. Bruno [1] https://gitlab.com/ghwiki/gnow-how/-/wikis/Platforms/Configuration