This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: underlying type for enums


On Tue, 2 Dec 2003 10:39:12 -0800, Richard Henderson <rth@redhat.com> wrote:

> 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.

I'd reverse those; an enum should not use unsigned int (and thus force
unsigned arithmetic) unless the enumerators won't fit in int.  That's the
promotion rule in C++, at any rate.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]