OSF DCE Application Development Guide--Core Components
Interface Definition Language
The union_name specifies a name to be used in C code generated by the IDL compiler.
When the IDL compiler generates C code to represent an IDL union, it embeds the union
and its discriminator in a C structure. The name of the IDL union becomes the name of
the C structure. If you supply a union_name in your type declaration, the compiler
assigns this name to the embedded C union; otherwise, the compiler assigns the generic
name tagged_union.
A case contains one or more labels and may contain a member declaration:
case constant:
...
[union_member];
Each label in a case specifies a constant. The constant can take any of the forms
accepted in an integer, character, or Boolean constant declaration, each of which is
described earlier in this chapter.
A default_case can be coded anywhere in the list of cases:
default:
[union_member];
A union_member takes the following form:
[[union_member_attribute, ...]] type_specifier declarator;
A union_member_attribute can be any of the following:
• ptr: An attribute indicating that the pointer member being declared is a full pointer;
it can be NULL and can be an alias.
• string: An attribute indicating that the character array member being declared is a
string.
In any union, the type of the discriminator and the type of all constants in all case labels
must resolve to the same type. At the time the union is used, the value of the
discriminator selects a member, as follows:
• If the value of the discriminator matches the constant in any label, the member
associated with the label is selected.
• If there is no label whose constant matches the value of the discriminator and there is
a default case, the default member is selected.
• If there is no label whose constant matches the value of the discriminator and there is
no default case, no member is selected and the exception rpc_x_invalid_tag is
raised.
Note that IDL prohibits duplicate constant label values.
A union_member can contain only one declarator. If no union_member is supplied, the
member is NULL; if that member is selected when the union is used, no data is passed.
But note that the discriminator is always passed.
A union cannot contain a pipe, a conformant array, a varying array, or any structure that
contains a conformant or varying array. A union also cannot contain a ref or unique
124245 Tandem Computers Incorporated 17− 27