Skip to main content

Attribute: warning disable, warning restore

The warning disable attribute has the effect that specific warnings are suppressed. The warning restore pragma reactivates a suppressed message.

This attribute can be used for every compiler warning. You can find a list of all possible compiler warnings in the CODESYS Development System in the project settings of a project (ProjectProject Settings, Compiler warnings category).

Syntax:

{warning disable <compiler ID>}

{warning restore <compiler ID>}

<compiler ID>: ID located at the beginning of an error or a warning message.

Example 292. Example

Compiler message:

typify code ...
C0195: Implicit conversion from unsigned Type 'UINT' to signed Type 'INT' : possible change of sign
Compile complete -- 0 errors

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 a warning; test2 generates a warning.