sizeof (integral types)

Richard Sargent richard at pantor.UUCP
Wed Apr 19 00:36:39 AEST 1989


austing at Apple.COM (Glenn L. Austin) in > Message-ID: <29127 at apple.Apple.COM>
writes:
> In article <10044 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) 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.
> 
> longs are guaranteed to be at least 24 bits (according to C++, sec 2.3.1)


procedure flame()
BEGIN
Please, if you are going to quote chapter and verse, do so in context.
Section 2.3.1 EXPLICITLY says "all that is guaranteed is [the usual <=
relationships]."  The sentence that Mr. Austin refers to begins "However,
it is usually reasonable to assume ... a long has at least 24 bits."

The immediate next sentence, in the same paragraph, says "Assuming more
is hazardous, and even this rule of thumb does not apply universally."

RTFM and quote it properly, too!

END;

Nothing in C or C++ is _guaranteed_ about sizes except
  1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long).

For all we may wish otherwise (at times), that's life, so let's just
live it.

Richard Sargent
Systems Analyst



More information about the Comp.lang.c mailing list