David Malone wrote:
>> 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
> language?
-std=gnu99 ≡ -std=c99 -D_GNU_SOURCE
I generally put #define _GNU_SOURCE at the top of all
my C programs that require it (i.e. most of them).
> 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.
Well it's documented correctly in my version of man pages.
You can browse or download the latest versions here:
http://www.kernel.org/doc/man-pages/
Note since you now need both _BSD_SOURCE and _XOPEN_SOURCE
I suggest you just define _GNU_SOURCE for simplicity.
Pádraig.
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!