LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] round and drand48

[ILUG] round and drand48

Pádraig Brady P at draigBrady.com
Thu Apr 10 13:11:03 IST 2008


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 â

[snip]

> 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_"
#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

$ echo "#include <features.h>" | cpp -dN -std=c99 | grep "#define __USE_"
#define __USE_ANSI
#define __USE_ISOC99
#define __USE_FORTIFY_LEVEL



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell