Skip to main content

Compiler Warning C0542

Message: Inheritance is not intended for the data type "UNION" <data type name>.

Possible error cause: A structured data type (DUT) is derived from a UNION by extending with EXTENDS, or a UNION is derived from a DUT. This kind of derivation is not permitted. However, for reasons of compatibility only a warning is issued.

Example 490. Example of the error:
TYPE U_StringExt EXTENDS U_StringBase :
UNION
    str10 : STRING(10);
END_UNION
END_TYPE
TYPE U_StringBase :
UNION
    str20 : STRING(20);
END_UNION
END_TYPE
PROGRAM PLC_PRG
VAR
    uStringExt : U_StringExt;
END_VAR

uStringExt.str20 := 'a234567890b234567890'; -> C0542