Mail Archives: djgpp/1998/01/21/18:40:36
At 05:35 1/21/1998 +0100, Van Mo Dang wrote:
>Eli Zaretskii wrote:
>
> > > 2 - Which file should be included to know their prototypes ?
>>
>> None. Just declare the prototype yourself.
>
>Thank you for your fast answer and the information.
>Isn't it kind of unusual that the prototypes of these functions
>are not declared in any constant header file?
>
>All C library functions I have used until now can be declared
>using a provided header file. I find it reassuring,
>because errors in copying the prototypes locally
>can be avoided by using such header files.
It does seem strange.
On other systems:
Linux (i386, libc 5) declares `random' and `srandom' in <stdlib.h>, but
inside "#ifdef __USE_BSD".
4.4 BSD (FreeBSD 2.0.5, i386) has them in <stdlib.h> also, but inside
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
I know GCC defines _ANSI_SOURCE if you compile with `-ansi'.
Both declare them as follows:
long int random (void);
void srandom (unsigned int);
Given this, I think it's strange that DJGPP's <stdlib.h> doesn't declare
them. IMHO, it should, although of course inside the appropriate #define to
keep ANSI programs from seeing them.
>This makes me hesitate somewhat to use random() and srandom(),
>although those RNG are said to provide "better" (in which sense
>exactly?) random numbers than rand() and srand().
`random' has a much more sophisticated scheme for generating random numbers,
which is said to result in more randomness, especially in the low-order bits
of the number. `rand' is a simple linear congruential (is that right?) RNG.
This is true on DJGPP anyway, YMMV on other systems. Compare the sources if
you wish, and be amazed. Also `rand' is ANSI.
Oh yeah, `random' on DJGPP is the actual BSD code, so using it in a binary
may require you to credit the Regents of the University of California in
your documentation. I'm no lawyer, though.
Linux uses the same code for both `rand' and `random', which is (I think)
GNU's own RNG. IMHO, DJGPP should make both interfaces "good" RNG's like
`random' is. It's not clear what the legal issues of that are, though;
naming BSD's `random' something else may do strange copyright things. What
would really be nice would be for someone to write their own, good RNG and
donate it to DJGPP...
Nate Eldredge
eldredge AT ap DOT net
- Raw text -