#pragma enum
Category
Purpose
Specifies the amount of storage occupied by enumerations.
Syntax
Defaults
The default is small.
Parameters
- small
- Specifies that an enumeration occupies the minimum amount of storage
required by the smallest predefined type that can represent that range
of enumeration constants: either 1, 2, or 4 bytes of storage. If the
specified storage size is smaller than that required by the range
of the enumeration constants, the compiler issues a diagnostic message.
For example:
#pragma enum(1) enum e_tag { a=0, b=SHRT_MAX /* diagnostic message */ } e_var; #pragma enum(reset) - int
- Specifies that an enumeration occupies 4 bytes of storage and
is represented by
int. - 1
- Specifies that an enumeration occupies 1 byte of storage.
- 2
- Specifies that an enumeration occupies 2 bytes of storage.
- 4
- Specifies that an enumeration occupies 4 bytes of storage.
- 8
- Specifies that an enumeration occupies 8 bytes of storage. This suboption is only valid with LP64.
intlong- Specifies that an enumeration occupies 8 bytes of storage and
is represented as a
longif the range of the enumeration constants exceeds the limit for typeint. Otherwise, enumerations occupy 4 bytes of storage and are of typeint. This suboption is only valid with LP64.
- reset
- pop
- Sets the
enumsetting to that which was in effect before the current setting.
Usage
The directive is in effect until the next valid #pragma enum directive is encountered. For every #pragma enum directive in your program, it is good practice to have a corresponding #pragma enum(reset) or #pragma enum(pop) as well. This is the only way to prevent one file from potentially changing the enum setting of another file that is included.
You cannot
have #pragma enum directives within the declaration of an enumeration.
The following code segment generates a warning message and the second
occurrence of the pragma is ignored:
#pragma enum(small)
enum e_tag {
a,
b,
#pragma enum(int) /*cannot be within a declaration */
c
} e_var;Related information
For detailed information on the preferred sign and type for each range of enumeration constants, see the description of the ENUMSIZE compiler option in the z/OS XL C/C++ User's Guide
