Mail Archives: djgpp/1999/05/26/02:58:22
On Mon, 24 May 1999, Dlanor Blytkerchan wrote:
> When stepping through this in RHIDE, watching errno like a hawk, immediatly
> after srand(time(0)); errno is set to 22 (ENOENT)
That's because `time' looks for the timezone files on your system, to
correctly handle the DST (Daylight Saving Time) rules. I guess you
didn't install djtzn202.zip, right? (See section 22.19 of the FAQ for
more details.)
I believe there's nothing wrong in this behavior of `time'. The ANSI
C standard says this:
... The value of `errno' may be set to nonzero by a library
function call whether or not there is an error, provided the use of
`errno' is not documented in the description of the function in
[the ANSI C Standard].
Since the description of `time' in the ANSI C Standard doesn't include
any references to `errno', `time' is free to assign non-zero values to
`errno'.
> (and thus causes my
> program to believe there's an error, which it wisely ignores).
I think this is a bug in your program. Programs should only examine
`errno' if they have other, independent means to indicate that the
last function call failed. In the case of `time', it will return -1
if it fails; *then* you could use `errno' value to find out why it
failed.
- Raw text -