Floating-point and integer control
Specifies the amount of storage occupied by enumerations
.-SMALL---. >>-ENUM--(--+-INT-----+--)------------------------------------->< +-INTLONG-+ +-1-------+ +-2-------+ +-4-------+ '-8-------'
ENUM(SMALL)
When the ENUMSIZE option is in effect, you can select the type used to represent all enum constants defined in a compilation unit.
The following tables illustrate the preferred sign and type for each range of enum constants:
ENUM Constants | small | 1 | 2 | 4 | 8 * | int | intlong * (C++ only) |
---|---|---|---|---|---|---|---|
0..127 | unsigned char | signed char | short | int | long | int | int |
-128..127 | signed char | signed char | short | int | long | int | int |
0..255 | unsigned char | unsigned char | short | int | long | int | int |
0..32767 | unsigned short | ERROR | short | int | long | int | int |
-32768..32767 | short | ERROR | short | int | long | int | int |
0..65535 | unsigned short | ERROR | unsigned short | int | long | int | int |
0..2147483647 | unsigned int | ERROR | ERROR | int | long | int | int |
-231..231-1 | int | ERROR | ERROR | int | long | int | int |
0..4294967295 | unsigned int | ERROR | ERROR | unsigned int | long | unsigned int (C++ only) ERROR for C | unsigned int |
0..(263-1) * | unsigned long | ERROR | ERROR | ERROR | long | ERROR | long |
-263..(263-1) * | long | ERROR | ERROR | ERROR | long | ERROR | long |
0..264 * | unsigned long | ERROR | ERROR | ERROR | unsigned long | ERROR | unsigned long |
The __ENUM_OPT macro is defined only by the C compiler, which predefines it to 1 when the ENUMSIZE option is in effect; otherwise it is undefined.
If the specified storage size is smaller than that required by the range of enum constants, an error is issued by the compiler; for example:
#include <limits.h>
#pragma enum(1)
enum e_tag {
a = 0,
b = SHRT_MAX /* error */
} e_var;
#pragma enum(reset)