c++ - arbitrarily sized enum values -
i'm compiling code written gcc, in visual c++ 2012. i'm getting warnings thrown enum value truncation following enum (due value being outside range of int):
enum tile_flags { tile_flag_inner_flame= 0x10000000ull, tile_flag_constricted= 0x20000000ull, tile_flag_mimic_inept 0x2000000000ull tile_flag_mimic 0x4000000000ull tile_flag_mimic_raven 0x6000000000ull tile_flag_mimic_mask 0x6000000000ull }
when compiling x86, appear msvc truncates enum values fit in 32bits. however, no truncation occurs in gcc. happening on gcc? , how can make work msvc?
from n3485, § 7.2/6:
for enumeration underlying type not fixed, underlying type integral type can represent enumerator values defined in enumeration. if no integral type can represent enumerator values, enumeration ill-formed. implementation-defined integral type used underlying type except underlying type shall not larger int unless value of enumerator cannot fit in int or unsigned int. if enumerator-list empty, underlying type if enumeration had single enumerator value 0.
therefore, if msvc has necessary long long
support, should make underlying type anyway. seeing how doesn't, there's 1 thing can try in order coax it.
specify underlying type:
enum tile_flags : unsigned long long { ... };
Comments
Post a Comment