switch_type attribute

The [switch_type] attribute identifies the type of the variable used as the union discriminant. The switch type can be an integer, character, Boolean, or enumeration type.

switch_type(switch-type-specifier)

Parameters

switch-type-specifier

Specifies an int, char, Boolean, or enum type, or an identifier of such a type.

Remarks

While the [switch_type] attribute identifies the variable type, the [switch_is] attribute specifies the name of the parameter that is the union discriminant. The [switch_type] attribute applies to parameters or members of structures or unions.

The union and its discriminant must be specified at the same logical level. When the union is a parameter, the union discriminant must be another parameter. When the union is a field of a structure, the discriminant must be another field of the structure at the same level as the union field.

Examples

typedef [switch_type(short)] union _WILLIE_UNION_TYPE 
{ 
    [case(24)] 
        float fMays; 
    [case(25)] 
        double dMcCovey; 
    [default] 
        ; 
} WILLIE_UNION_TYPE; 
 
typedef struct _WINNER_TYPE 
{ 
    [switch_is(sUniformNumber)] WILLIE_UNION_TYPE w; 
    short sUniformNumber; 
} WINNER_TYPE;

See also

Boolean

char

Encapsulated Unions

enum

Interface Definition (IDL) File

int

Nonencapsulated Unions

switch_is

union