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

David Malone dwmalone at maths.tcd.ie
Thu Apr 10 11:46:11 IST 2008


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 â

when I first use round.  This is bad, because round returns a double,
but the compiler will assume it returns an int.

If I do give this flag it then macros that tell glibc that I don't
want anything that isn't a C99 standard function, so then I get the
warning:

	warning: implicit declaration of function â

which is bad, because drand48 returns an double and the compiler
will think it returns an int.

I can think of two ways around this. First, I can explicitly give
my own declaration for drand48:

	extern double drand48(void);

but this is ugly 'cos I probably don't want to declare every function
that I might use. 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?

	David.



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