> You should not use the internal flags as you noted.
> Instead #define _XOPEN_SOURCE in addition to the -std=c99 flag
> For details on these macros see: info libc "feature test macros"
Ah - that works. It also works with -D_XOPEN_SOURCE on the command
line (-D__USE_XOPEN doesn't 'cos I think it gets redefined by gcc
or glibc internally later).
> An alternative is just to use the -std=gnu99 flag
Does that mean "the c99 language, plus any libraries and headers I
have installed"? I guess this also allows GNU extensions to the C
> Note they following can be handy to determine directly
> which features are set by the various options:
> $ echo "#include <features.h>" | cpp -dN | grep "#define __USE_"
> #define __USE_ANSI
> #define __USE_POSIX
> #define __USE_POSIX2
> #define __USE_POSIX199309
> #define __USE_POSIX199506
> #define __USE_XOPEN2K
> #define __USE_MISC
> #define __USE_BSD
> #define __USE_SVID
> #define __USE_FORTIFY_LEVEL
Is it documented anywhere what functions/macros depend on what
_*_SOURCE, or do you just have to read the header files to find
out? For example, I've just discovered that I also need -D_BSD_SOURCE
in order to get random() and srandom(), but this isn't obvious (to
me) from the glibc man pages.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!