sizeof (integral types)
Richard Sargent
richard at pantor.UUCP
Tue Apr 18 01:00:48 AEST 1989
gwyn at smoke.BRL.MIL (Doug Gwyn) in Message-ID: <10044 at smoke.BRL.MIL> writes:
>
> In article <12005 at paris.ics.uci.edu> Doug Schmidt <schmidt at glacier.ics.uci.edu> writes:
> >I realize the relation short <= int <= long holds, I'm just curious
> >whether there is any minimum that these basic types must meet (e.g.,
> >short >= 16 bits, etc.).
>
> chars are at least 8 bits,
> shorts are at least 16 bits,
> longs are at least 32 bits.
I quote from the ANSI C DRAFT dated January 11, 1988, Section 3.1.2.5:
An object declared as type char is large enough to store any member
of the basic execution character set. ...
There are four _signed integer types_, designated as signed char,
short int, int, and long int. ...
... A "plain" int object has the natural size SUGGESTED by the
architecture of the execution environment ( ... in the header <limits.h>).
In the list of signed integer types above, the range of values of each
type is a subrange of the values of the next type in the list.
Please note that this definition explicitly avoids any claims about the sizes
of the types except for the "<=" business in the first message. It most
definitely does NOT say anything about 8, 16, or 32 bits! In fact, the
definition permits implementations of 8 bit longs and others of 32 bit chars!
(Of course, no one in their right mind would try to sell such a product,
but it is not forbidden by the language definition.)
Richard Sargent
Systems Analyst
More information about the Comp.lang.c
mailing list