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, which is located at the start of a warning message or in the overview of the compiler warnings in the PLC project properties.

Sample:

Compiler warning:

C0195: Implicit conversion from unsigned Type 'UINT' to signed Type 'INT' : possible change of sign

Applying the pragma to a variable declaration:

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

test1 does not generate an error message, test2 generates an error message.

 

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: