ANSI C date & time library functions.

Henry Spencer henry at utzoo.uucp
Sun Feb 11 09:02:47 AEST 1990


In article <Ccvioy2 at cs.psu.edu> flee at shire.cs.psu.edu (Felix Lee) writes:
>Are you allowed to compare time_ts without using difftime()?  Or
>should I write "difftime(now, then) < 0" instead of "now < then"?

There is explicitly no guarantee of the internal representation of time_t.
Since it is an arithmetic type, you can do direct comparisons... but there
is no guarantee that the result will be meaningful.  If you want portable
comparisons, difftime() is indeed the correct method.

>Can time_t be a pointer (converted to an arithmetic if necessary)?
>...This is assuming you don't compare time_t values directly and don't
>try to read or write them.

Unfortunately, there is way too much existing code which assumes that
a time_t can be assigned, passed around, etc.  A pointer is not an
arithmetic type and hence is not a legal time_t type.
-- 
SVR4:  every feature you ever |     Henry Spencer at U of Toronto Zoology
wanted, and plenty you didn't.| uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.std.c mailing list