question on using random in C on FC4 (perhaps slightly OT)
STYMA, ROBERT E (ROBERT)
stymar at lucent.com
Wed Nov 16 15:00:33 UTC 2005
>
> 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
More information about the fedora-list
mailing list