FW: Definition of time_t changed from signed to unsigned...

Paul Eggert eggert at CS.UCLA.EDU
Tue Jul 13 05:50:12 UTC 2004

Guy Harris <guy at alum.mit.edu> writes:

> I infer from "size_t shall be an unsigned integer type" that "integer
> type" means "signed integer type" as opposed to "unsigned integer type";

This doesn't sound right to me.  In POSIX and C99, "integer type"
means either "char", or a signed integer type, or an unsigned integer
type, or an enumeration; for the formal definition please see ISO/IEC
9899:1999 page 35 section 6.2.5 paragraph 17.

This usage can also be seen in POSIX.  For example,
says the following:

  * off_t is a signed integer type.
  * size_t is an unsigned integer type.
  * uid_t is an integer type.

This illustrates three possibilities for integer types:

  * ((off_t) -1) must be less than zero.

  * ((size_t) -1) must be greater than zero.

  * POSIX doesn't say whether ((uid_t) -1) is less than or greater
    than zero, though one or the other must be true on any
    particular implementation.

When POSIX says that time_t is an integer or real-floating type, it
allows all sorts of possibilities.  time_t might be any arithmetic
type (including bool!) -- except that complex and imaginary numbers
are excluded, thank goodness.

In practice, time_t is almost always 'long int' or 'int'.  Other
implementations exist, but they're rare.

More information about the tz mailing list