Hi Reuben, > I find that some APIs on GNU systems need > extra treatment (i.e. GNU is not POSIX-1.2001 by default). For > example, for crypt(3) I need to define _XOPEN_SOURCE
For crypt() to be declared in <crypt.h>, you need nothing. But for it to be declared in <unistd.h>, you need _XOPEN_SOURCE or _GNU_SOURCE. _GNU_SOURCE means "make all extensions in the header files visible". $ cat foo.c #define _GNU_SOURCE 1 #include <unistd.h> $ gcc -E foo.c | grep crypt extern char *crypt (__const char *__key, __const char *__salt) extern void encrypt (char *__block, int __edflag) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))); > I can't find any gnulib extensions that bear on this: extensions is > already running because of something else The 'extensions' module sets _GNU_SOURCE, so it is this module which you want and need. Note that <config.h> must be the first header file to be included in every compilation unit. If you don't include it, _GNU_SOURCE will not be defined, and if you include it too late, <features.h> has already made the decision whether to defined __USE_XOPEN or not. > The crypt example is particularly annoying, as without _XOPEN_SOURCE > defined it's not defined, even though POSIX_VERSION is >= 200112L, and > it's in that version of POSIX (of course, that's a glibc bug $ cat foo.c #define _POSIX_C_SOURCE 200112L #include <unistd.h> $ gcc -E foo.c | grep crypt Indeed crypt() is on POSIX:2001 <http://pubs.opengroup.org/onlinepubs/009604499/functions/crypt.html>. But it is marked as [XSI]. I don't know whether that implies that glibc is right in hiding the declaration, or it should enable it? > Have I missed anything, or is this a gap in gnulib's coverage? Certainly the fact that crypt() is not defined by default could be mentioned in doc/posix-functions/crypt.texi. Bruno -- In memoriam Joseph Lee Heywood <http://en.wikipedia.org/wiki/Joseph_Lee_Heywood>