How soon can `sizeof (tagged_type)' be used?
Norman Diamond
diamond at jit533.swstokyo.dec.com
Tue May 21 10:55:59 AEST 1991
Erik Naggum writes:
>| What is "sizeof (enum E)" supposed to return if not the same as
>| "sizeof (int)"?
Norman Diamond writes:
>| sizeof (short), sizeof (long), or sizeof (other_integral_type...)
Erik Naggum:
>Right. There's a subtle difference between the type of enumerators
>and the enumeration type itself. ... the former have type int, while
>the enumerated type "shall be compatible with an integer type; the choice
>of type is implementation-defined". (Why this is so escapes me.)
Variables can be declared with the enumeration type, and their storage
requirements are determined accordingly. But enumerators are just constants.
The constants 5200 and 'x', for example, have type int, even though they can
fit in shorts; but they're just constants and aren't necessarily stored.
--
Norman Diamond diamond at tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.
More information about the Comp.std.c
mailing list