Specifying the underlying type for an enum is a C++11 language feature. To get the code to compile, you must add the switch -std=c++11
. This works for both GCC and Clang.
For enums in C++03, the underlying integral type is implementation-defined, unless the values of the enumerator cannot fit in an int or unsigned int. (However, Microsoft’s compiler has allowed specifying the underlying type of an enum as a proprietary extension since VSĀ 2005.)