PreviousNext

Enumeration

An IDL enumeration provides names for integers. It is specified as follows:

enum {identifier[=integer], ...}

Each identifier in an enumeration is assigned an integer, either explicitly in the interface or automatically by the IDL compiler. If all the identifiers are unassigned, the IDL compiler begins assigning 0 (zero) to the first identifier, 1 to the next identifier, and so on. If an unassigned identifier follows an assigned one, the compiler restarts number assignment with the next consecutive integer. An enumeration can have up to 32,767 identifiers.

Assignments can be made in any order, and multiple identifiers can have the same value. For example:

typedef enum {
SHOVEL = 9, AX, MATTOCK = 3, PITCHFORK, SPADE = 9
} yard_tools;
/* values assigned: SHOVEL:9, AX:10, MATTOCK:3, PITCHFORK:4, */
/*SPADE:9 */