Mail Archives: djgpp/2000/06/28/16:15:24
"Tim \"Zastai\" Van Holder" <zastai AT hotmail DOT com> writes:
> This seems exctly right to me. 'enum' isn't a type, so the sizeof operator
> can't legally be applied to it.
> 'enum foo', 'enum bar' and 'enum foobar' ARE type, and you can apply sizeof
> to them. Note that in theory, the compiler is allowed to decide the size of
> an enum by looking at the range of values it contains; an enum containing
> just values between -127 and 128 (or between 0 and 255) could be put in
> single byte, while an enum using -12 and 2375 would require 2 bytes, and so
> on. in practice, usually an int is used, as shown below:
[...]
> NOTE: Optimizations (including -Os) do NOT affect this -- gcc always uses
> int-sized storage for enums.
Unless you specify -fshort-enums.
--
Nate Eldredge
neldredge AT hmc DOT edu
- Raw text -