Pragmas 'warning disable', 'warning restore'

The pragma {warning disable <compiler ID>} causes certain warnings to be suppressed.

The pragma {warning restore <compiler ID>} reactivates a suppressed message.

Syntax:

{warning disable <compiler ID>}

{warning restore <compiler ID>}

<compiler ID>: ID that is located at the start of a warning message or in the overview of the compiler warnings in the PLC project properties.

Example for C0195 compiler warning:

Compiler warning:

C0195: Implicit conversion from signed type 'SINT' to unsigned type 'UINT': possible change of sign

Apply the pragma to a variable declaration:

VAR
    {warning disable C0195}
    test1 : UINT := -1;
    {warning restore C0195}
    test2 : UINT := -1; 
END_VAR

test1 generates no warning, test2 generates a warning.

Example for C0394 compiler warning:

Compiler warning:


C0394: Compatibility warning: FB_Exit is now called in F_Sample for FB instance fbSample which is located on the stack. This has not been the case for code compiled with compiler versions < 3.1.4022.0.

Apply the pragma to a POU declaration:

{warning disable C0394}
FUNCTION F_Sample : BOOL
VAR_INPUT
    bInput   : BOOL;
END_VAR
VAR
    fbSample : FB_Sample;   // The function block FB_Sample contains the method FB_exit
END_VAR

If the pragma is not used, the above warning is issued for the fbSample function block instance. If the pragma mentioned in the example is used, however, no warning is generated.

 

Pragmas 'warning disable', 'warning restore' 1:

Pragmas in the implementation editor

If you wish to use the pragmas to suppress warnings in the implementation editor, this is currently possible in the ST editor as well as in the FBD/LD/IL editor.

In FBD/LD/IL, the desired pragma must be entered in a label.

 

See also: