Example: union

In the following example, a union, mixed,contains just one of either the character, radian, or number fields. Two instances of the union, a and b, are then used in the function Actions.

    union mixed {
        char character;
        float radian;
        int number;
    union mixed a, b;
    a.number = 7;
    b.character = 'e';
    lr_output_message ("number value is %d", a.number);
    lr_output_message ("character value is %c", b.character);
Example: Output:
Action.c(14): number value is 7
Action.c(15): character value is e