enum

enum [tag ] identifier [=integer-value ] [ , ... ] }

tag

Specifies an optional tag for the enumerated type.

identifier

Specifies the particular enumeration.

integer-value

Specifies a constant integer value.

 

Examples

typedef enum { Monday=2, Tuesday, Wednesday, Thursday, Friday} workdays;

 

typedef enum { Clemens=21, Palmer=22, Ryan=34} pitchers;

 

Remarks

The keyword enum is used to identify an enumerated type. 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 IDLJ2VTYS.

In the MIDL compiler s default mode, you can assign integer values to enumerators. (This feature is not available when you compile with the /osf1..7ZU2 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_enum12ER4XL attribute to the enum typedef.

See Also

IDL, typedef, v1_enum