However, if the ANSI Strict option is off, enumerators that can be represented as an unsigned int are implicitly converted to signed int. For example:
#pragma enumsalwaysint on
#pragma ANSI_strict on
enum foo { a=0xFFFFFFFF }; // ERROR. a is 4,294,967,295:
// too big for a signed int
#pragma ANSI_strict off
enum bar { b=0xFFFFFFFF }; // OK: b can be represented as an
// unsigned int, but is implicitly
// converted to a signed int (-1).See "ANSI Strict" for additional features of that setting.
To be more precise, if Enums Always Int is off, the compiler picks one of the following:
#pragma enumsalwaysint off
enum { a=0,b=1 }; // base type: unsigned char
enum { c=0,d=-1 }; // base type: signed char
enum { e=0,f=128,g=-1 }; // base type: signed short
The compiler will use long long data types only if Enums Always Int is off and the longlong_enums pragma is on. (There is no settings panel option corresponding to the longlong_enums pragma.)
#pragma enumsalwaysint off
#pragma longlong_enums off
enum { a=0x7FFFFFFFFFFFFFFF }; // ERROR: a is too large
#pragma longlong_enums on
enum { b=0x7FFFFFFFFFFFFFFF };// OK: base type: signed long long
enum { c=0x8000000000000000 };// OK: base type: unsigned long long
enum {þd=-1,e=0x80000000 }; // OK: base type: signed long long
When the longlong_enums pragma is off and ANSI Strict is on, you cannot mix unsigned 32-bit enumerators greater than 0x7FFFFFFF and negative enumerators. If both the longlong_enums pragma and the ANSI Strict option are off, huge unsigned 32-bit enumerators are implicitly converted to signed 32-bit types.
#pragma enumsalwaysint off
#pragma longlong_enums off
#pragma ANSI_strict on
enum { a=-1,b=0xFFFFFFFF }; // error
#pragma ANSI_strict off
enum { c=-1,d=0xFFFFFFFF }; // base type: signed int (b==-1)
The Enums Always Int option corresponds to the pragma enumsalwaysint. To check whether this option is on, use __option (enumsalwaysint). By default, this option is off.
See also "enumsalwaysint", "longlong_enums", and "Checking Options."