Skip to main content

Compiler Warning C0354

Message: Comparison of one enumeration type (<type name 1>) with another (<type name 2>)

Possible error cause: Enumeration types are used in comparison operators.

Error correction:

  • Use predefined integer data types (example: INT) instead of enumeration types in your program code.

  • Copy the values of the enumeration variables into auxiliary variables (example: INT variables) and use the auxiliary variables in the comparison operator.

Example 468. Example of the warning
{attribute 'qualified_only'}
{attribute 'strict'}
TYPE ENUM1:
(
      enum_member1 := 0,
      enum_member2 := 1
);
END_TYPE

{attribute 'qualified_only'}
{attribute 'strict'}
TYPE ENUM2:
(
      enum_member := 0
);
END_TYPE

PROGRAM PLC_PRG
VAR
      enum1 : ENUM1;
      enum2 : ENUM2;
      i:INT;
END_VAR
enum1 := 0;
enum2 := 0;
IF enum1 > enum2 THEN
      i := 1;
END_IF;

The IF statement produces the following warning.

Message:

C0354: Comparison of one enumeration type (ENUM1) with another (ENUM2)