delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/05/21/06:09:43

Date: Tue, 21 May 2002 13:05:35 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alex Vinokur <alexvn AT bigfoot DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: mktime() & time_t
In-Reply-To: <acd0k2$obovm$1@ID-79865.news.dfncis.de>
Message-ID: <Pine.SUN.3.91.1020521130306.7489A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 21 May 2002, Alex Vinokur wrote:

> | > However : May mktime() return -1 ?
> |
> | It's in the docs: mktime returns -1 if you feed it with time outside the
> | range of dates it can represent.
> 
> But in this case mktime() returns UINT_MAX ( not  -1 ) because time_t if of 'unsigned int' type.

The bit patterns of UINT_MAX and -1 are exactly the same in DJGPP, so 
these are just two different names for the same value.

The reason the docs doesn't say UINT_MAX is that time_t can be signed on 
some platforms, unsigned on others.  Using -1 for comparison makes your 
programs more portable.  Especially since the C standard and Posix both 
say mktime should return -1 if it fails.

The same situation occurs with functions like `read' and `write', IIRC.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019