E122: Invalid enum base type
This error occurs when an enum is declared with a base type that is not a valid integer type. Enums in IEC 61131-3 can only use integer types as their underlying representation.
Example
TYPE Color : STRING (red := 1, green := 2, blue := 3);
END_TYPE
TYPE Status : REAL (active := 1, inactive := 0);
END_TYPE
TYPE Timestamp : TIME (start := 0, stop := 1);
END_TYPE
These examples show invalid base types:
STRINGis not a valid base type for an enum. Only integer types are allowed.REALis a floating-point type, not an integer typeTIMEis a time/date type, which although internally represented as an integer, should not be used as an enum base type
Valid integer types
The following integer types are valid for enum base types:
INT,UINT- 16-bit integersSINT,USINT- 8-bit integersDINT,UDINT- 32-bit integersLINT,ULINT- 64-bit integersBYTE- 8-bit unsignedWORD- 16-bit unsignedDWORD- 32-bit unsignedLWORD- 64-bit unsigned
How to fix
Use a valid integer type
Change the base type to one of the supported integer types:
TYPE Color : INT (red := 1, green := 2, blue := 3);
END_TYPE
TYPE Status : BYTE (active := 1, inactive := 0);
END_TYPE
Or omit the type specification
If no specific size is required, you can omit the type specification (will default to DINT):
TYPE Color (red := 1, green := 2, blue := 3);
END_TYPE