2012/2/5 David Brown :
>
> Enum types in C++ can be any integer type big enough to cover the required
> range.  I think most C++ compilers use the smallest integer type that covers
> the range.

With the three C++ compilers I tried enums are int-sized for
compatiblity reasons, so that enums declared in a header file included
by C code and C++ code will agree on the type layout.

C++11 allows you to fix the underlying type of an enum, to use a specific size:

enum E : unsigned char { E1, E2 };

The syntax isn't valid in C, so there's no reason to use the same
layout as a C enum would.

Reply via email to