union

This statement defines a C-style union.

Syntax

typedef [attributes] union [tag] {
    memberlist
} unionname;

Syntax Elements

attributes
The attributes helpstring, helpcontext, uuid, hidden, and version are accepted before a union. The helpstring, helpcontext, and string attributes are accepted on a union member. For more information about the attributes accepted before a union definition, see "Attribute Descriptions" earlier in this chapter. Attributes (including the square brackets) can be omitted. If uuid is omitted, the union is not uniquely specified in the system.
tag
An optional tag, as with a C union.
memberlist
List of union members defined with C syntax.
unionname
Name by which the union is known in the type library.

Comments

The union keyword must be preceded with a typedef. The union description must precede other references to the structure in the library. Members of a union can be of any built-in type, or any type defined lexically as a typedef before the union. For a description of how strings and arrays can be entered, see the sections "String Definitions" and "Array Definitions" earlier in this chapter.

Example

[uuid(BFB7334C-822A-1068-8849-00DD011087E8), helpstring("A task"), helpcontext(1019)] 
typedef union {
    COLOR polycolor;
    int    cVertices;
    boolean filled;
    SAFEARRAY (int) subtasks; 
} UNIONSHOP;