The type of time_t (was: struct tm -> time_t converter wanted)

Alan J Rosenthal flaps at dgp.toronto.edu
Mon Oct 24 03:38:52 AEST 1988


karl at haddock.ima.isc.com (Karl Heuer) writes:
>>There's nothing to prevent time_t from being typedef'd to unsigned long int,
>>which would double the range...

henry at utzoo.uucp (Henry Spencer) writes:
>Unfortunately, it would probably break a significant number of programs that
>think time_t is signed.  Those programs are arguably broken already, but some
>degree of pragmatism is necessary in such matters.

Is it possible to assume that time_t is signed without assuming it's either
int or long (or char)?  I can't see how, and if it's not then Karl's change
above wouldn't break any more programs than changing time_t between int and
long would.

(It is true that a cast to long sort of assumes that the value cast is signed,
but in the case of time_t I don't see what you want to do with that value
except cast it back to time_t, which makes the cast to long rather pointless.
Or if you want to printf the number, well ansi printf's %lu format takes a
long, not an unsigned long, anyway, so the cast to long is the correct way to
print unsigned longs as well as longs.)

ajr

--
#define __STDC__ 0



More information about the Comp.std.c mailing list