RE: question on using random in C on FC4 (perhaps slightly OT)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> OK, now I have a real question: on my machine, I try the following....
> 
> 
>
...
> So, ignoring this, I use the following in a random number 
> generator program and
> get the following while compilation....
> 
> gcc -c -O3 -std=c99 -Wall -pedantic random.c
> random.c: In function 'setseed':
> random.c:35: warning: implicit declaration of function 'srandom'
> random.c: In function 'runi':
> random.c:48: warning: implicit declaration of function 'random'
> 
> But I have included stdlib.h so what is the problem?
>
For whatever reason, the declare for srandom in 
/usr/include/stdlib.h is surrounded by the #ifdef

#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD 

For testing you could try setting one of these via -D__USE_BSD on
your gcc command line.  Being these preprocessor variables have 
leading double underscores, they are probably set when some other
preprocessor variable is set.  It would take a bit of looking to determine
what causes these variables to be set.

You can test which preprocessor variables are defined by
default with:

cpp -dM < /dev/null

Hope this helps.

Bob Styma


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux