David Malone wrote:
> I want to use both the c99 function round() and the drand48() function
> in a single C program. To get the round() function on a recent
> version of Ubuntu I need to give gcc the "--std=c99" flag, otherwise
> I get the warnings:
>> warning: incompatible implicit declaration of built-in function â
> Slightly less ugly is that I can mess with glibc's
> internal macros before including stdlib.h:
>> #define __USE_XOPEN
> #include <stdlib.h>
>> This works, but I can't say I'm that happy with it. Does anyone
> know what the blessed way of doing this on recent Linux/glibc/gcc
> boxes is?
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"
An alternative is just to use the -std=gnu99 flag
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_"
$ echo "#include <features.h>" | cpp -dN -std=c99 | grep "#define __USE_"
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!