enum attribute
The keyword enum identifies an enumerated type.
enum [tag ]
{
identifier [=integer-value ]
[ , ... ]
}
Parameters
-
tag
-
Specifies an optional tag for the enumerated type.
-
identifier
-
Specifies the particular enumeration.
-
integer-value
-
Specifies a constant integer value.
Remarks
enum types can appear as type specifiers in typedef declarations, general declarations, and function declarators (either as the function-return-type or as a parameter-type specifier). For the context in which type specifiers appear, see Interface Definition (IDL) File.
In the MIDL compiler's default mode, you can assign integer values to enumerators. (This feature is not available when you compile with the /osf switch.) As with C-language enumerators, enumerator names must be unique, but the enumerator values need not be.
When assignment operators are not provided, identifiers are mapped to consecutive integers from left to right, starting with zero. When assignment operators are provided, assigned values start from the most recently assigned value.
The maximum number of identifiers is 65,535.
Objects of type enum are int types, and their size is system-dependent. By default, objects of enum types are treated as 16-bit objects of type unsigned short when transmitted over a network. Values outside the range 0 - 32,767 cause the run-time exception RPC_X_ENUM_VALUE_OUT_OF_RANGE. To transmit objects as 32-bit entities, apply the [v1_enum] attribute to the enum typedef.
Examples
typedef enum {Monday=2, Tuesday, Wednesday, Thursday, Friday} workdays;
typedef enum {Clemens=21, Palmer=22, Ryan=34} pitchers;
See also