The Diagnostic Message Pragmas

The following pragmas can be used to control diagnostic messages in the same ways as the corresponding command line options:

Pragma Option Description
diag_suppress num -pds=num[, num2, num3...] Suppress diagnostic num
diag_remark num -pdsr=num[, num2, num3...] Treat diagnostic num as a remark
diag_warning num -pdsw=num[, num2, num3...] Treat diagnostic num as a warning
diag_error num -pdse=num[, num2, num3...] Treat diagnostic num as an error
diag_default num n/a Use default severity of the diagnostic
diag_push n/a Push the current diagnostics severity state to store it for later use.
diag_pop n/a Pop the most recent diagnostic severity state stored with #pragma diag_push to be the current setting.

The syntax of the diag_suppress, diag_remark, diag_warning, and diag_error pragmas in C is:

#pragma diag_xxx [=]num[, num2, num3...]

Notice that the names of these pragmas are in lowercase.

The diagnostic affected (num) is specified using either an error number or an error tag name. The equal sign (=) is optional. Any diagnostic can be overridden to be an error, but only diagnostic messages with a severity of discretionary error or below can have their severity reduced to a warning or below, or be suppressed. The diag_default pragma is used to return the severity of a diagnostic to the one that was in effect before any pragmas were issued (i.e., the normal severity of the message as modified by any command-line options).

The diagnostic identifier number is output with the message when you use the -pden command line option. The following example suppresses a diagnostic message and then restores the previous diagnostics severity state:

#pragma diag_push #pragma diag_suppress 551 #pragma CHECK_MISRA("-9.1") #pragma diag_pop