Skip to main content
Search

Data Structure: UNION

A UNION is a data structure with usually different data types.

In a union, all components have the same offset and therefore the same amount of storage space.

TYPE NAME_AB:
UNION
        a : LREAL;
        b : LINT;
END_UNION
END_TYPE

If the NAME_AB type is written to a nameVar variable in the code, then this affects both nameVar.a and nameVar.b.