underlying type for enums
Richard Earnshaw
rearnsha@arm.com
Tue Dec 2 19:50:00 GMT 2003
> On Tue, Dec 02, 2003 at 09:31:16AM -0800, Zack Weinberg wrote:
> > But is this the right way to look at it? How do we handle "int foo :8"
> > and why is it different (apparently) from the way we handle
> > "enum blah foo :8" ?
>
> For C90 we must choose a compatible type that is a standard integer type.
> Due to existing ABI constraints, this must be "unsigned int" most of the
> time, and (for 32-bit targets) "int" the rest of the time. "long" should
> not enter into it at all until it's larger than "int", and "long long" is
> not a standard type in C90, so we have to pedwarn if we must use it.
>
> Due to the ABI constraints, you can tell when we've cheated and used
> something smaller than int based on promotion rules.
>
> As for the rest of your question, it depends on how C90 interprets
> the type of "int foo:8". I'll go into the office today and locate
> my dead tree edition of C90...
>
Don't forget ABIs that use -fshort-enums
R.
More information about the Gcc
mailing list