In addition to the basic types, the Interface Definition Language (IDL) also supports three constructed types:
The structure and enumeration types are specified in the IDL just as they are in C and C++. However, they have the following restrictions:
struct myStruct { long x; double y; }; /* defines type name myStruct */ enum colors { red, white, blue }; /* defines type name colors */
The following IDL definitions are not valid:
typedef struct myStruct { /* NOT VALID */ long x; /* Tag myStruct is the same */ double y; /* as the type name below; */ } myStruct; /* myStruct has been redefined */ typedef enum colors { red, white, blue } colors; /* NOT VALID */
The IDL union type is a cross between the C union and switch statements. This type is specified in IDL just as it is in C and C++, with the restriction that discriminated unions in IDL must be tagged. The syntax of a union type declaration is as follows:
union identifier switch (switch-type) { case+ }
case-label+ type-spec declarator;
where:
case const-expr:
default: The const-expr is a constant expression that must match or be automatically castable to the switch-type. A default case can appear no more than once.
Note: A deviation from CORBA specifications exists; there is no support of longlong discriminators in unions.