Mail Archives: djgpp/1998/01/21/12:13:43
On 21 Jan 98, Van Mo Dang was found to have commented thusly:
> I would have two questions about random() and srandom() :
>
> 1 - Are those routines portables ? I found them both in DJGPP
> and on Solaris systems, but can they be considered to be available
> in any C standard library ?
I don't have any copy of the ANSI C standard and what functions are
considered to be part of the library. (Where can that be had?)
However, I can say that your functions originated with the Berkeley
distribution (even the DJGPP include on the functions mentions it),
and so they may be POSIX but not ANSI. The functions rand() and
srand() are the equivalents in SVR4 Unix (USL), but I cannot say if
they are standard functions; my man page tells me that drand48() and
random() are more "elaborate" and produce a better distribution.
Newsgroup comp.lang.c probably is the place to look for the final
word on portability.
>
> 2 - Which file should be included to know their prototypes ? On
> Solaris, it seems that neither <stdio.h> nor <stdlib.h> contain any
> prototype of random() and srandom(). Actually none of the ".h"
> files in /usr/include contains their declaration.
That's the darnedest thing for me too. Grep on my /usr/include and
/usr/include/sys on a system running SVR4 doesn't pull out the
prototype for those, even though they are available. I guess you
can just set up your own header or put the prototypes at the start of
your source in the appropriate location. Don't yank out the DJGPP
prototypes and put them in however. Check the man pages on the
Solaris and yank them out of there.
Mitch Halloran
Research (Bio)chemist
Duzen Laboratories Group
Ankara TURKEY
mitch AT duzen DOT com DOT tr
other job title: Sequoia's (dob 12-20-95) daddy
- Raw text -