Date: Wed, 26 May 1999 09:56:06 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Dlanor Blytkerchan cc: djgpp AT delorie DOT com Subject: Re: srand() or time() In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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.