This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: underlying type for enums
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Zack Weinberg <zack at codesourcery dot com>, jsm at polyomino dot org dot uk, Jason Merrill <jason at redhat dot com>, gcc at gcc dot gnu dot org, Richard dot Earnshaw at arm dot com
- Date: Tue, 02 Dec 2003 19:46:45 +0000
- Subject: Re: underlying type for enums
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> 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.