Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 2.2 KB

devenv-directive-pragma-warning.md

File metadata and controls

62 lines (46 loc) · 2.2 KB
title description author ms.date ms.topic ms.author ms.reviewer
Pragma Warning directive in AL
The pragma warning instruction on the pragma directive in AL.
SusanneWindfeldPedersen
03/19/2024
conceptual
solsen
solsen

Pragma Warning directive in AL

[!INCLUDE2020_releasewave2]

The #pragma warning instruction can enable or disable certain warnings. This can be used as a solution to avoid getting warnings on, for example, string length on fields that you can't change. With the #pragma warning disable statement you disable the emit of the warning for a specific location in code, and with #pragma warning restore you restore the warning back to its original state. If you don't restore, the disable instruction is valid for the rest of the file.

Important

It's important to be aware that most warnings are there for a reason, and suppressing them could lead to sudden impact if warnings are changed to errors, such as obsoletes.

Syntax

#pragma warning disable warning-list  
#pragma warning restore warning-list  

Parameters

warning-list A comma-separated list of warning numbers.

When no warning numbers are specified, disable disables all warnings, and restore enables all warnings.

Note

To find warning numbers in AL, build your AL project in Visual Studio Code and then look for the warning numbers in the Output window. For more information, see Using the Code Analysis Tool.

Example

The following example illustrates how the specific rule AL0468 is temporarily turned off for a specific field definition.

table 50110 MyTable
{
    fields
    {
        #pragma warning disable AL0468
        field(1; TableWithLongIdentifierThatExceedsOurMax; Integer) { }
        #pragma warning restore
    }
}

See also

Development in AL
AL development environment
Pragma directive in AL
Conditional directives
Deprecating explicit and implicit with statements