question about an array of enum
Stephen Clamage
steve at taumet.com
Wed Nov 7 04:20:45 AEST 1990
gary at hpavla.AVO.HP.COM (Gary Jackoway) writes:
>I don't think a compiler can make enums smaller than int and be ANSI
>compliant, since the standard says that enums are ints.
That's not quite what the standard says. It says (3.5.2.2) that
the enum identifiers have type int, but that
"Each enumerated type shall be compatible with an integer type;
the choice of type is implementation-defined."
So given:
enum color { red, yellow, blue };
The constants red, yellow, and blue each have type int, but you
cannot predict the value of sizeof(enum color). It could be
anything from sizeof(char) to sizeof(long).
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.lang.c
mailing list