Mail Archives: djgpp/2002/05/21/06:09:43
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 -