Skip to main content

SA0051: Comparison operations on BOOL variables

Detects comparison operations on variables of type BOOL

Justification: CODESYS allows these kinds of comparisons. But they are very unusual and can be confusing. The IEC 61131-3 standard does not provide for these comparisons. By avoiding them, you increase the portability of the code to other development systems.

Importance: Medium

Example 61. Example
PROGRAM PLC_PRG
VAR
    xBool1, xBool2 : BOOL;
    xResult : BOOL;
END_VAR
xResult := xBool1 > xBool2;    // SA0051
xBool1 := NOT xBool1;    // OK!
xBool2 := xBool2 XOR xBool1;    // OK!

Output in the Messages view:

  • sa_icon_message.png SA0051: Comparison operations on BOOL variables