Example 17 Enabling warnings selectively
$cadvise +wall
5.4 Interpreting selective warnings as errors
The +Wearg1[,arg2,..,argn] option selectively interprets specified warning messages as errors. arg1 through argn must be valid warning message numbers. This option allows you to enforce a policy to disallow specific warnings by forcing an error at compile time.
+Wearg1[,arg2,..,argn]
Following is the syntax for selectively enabling warnings.
$cadvise +wall
Following is an example for selectively enabling warnings.
Example 18 Interpreting selective warnings as errors
$cadvise +wall
5.5 Disabling warnings in a macro
The +Wmacro:MACRONAME:d1,d2,d3,..dn option disables specified warnings in a macro. MACRONAME is the name of the macro and d1, d2, d3, ..., dn are warning numbers. Specifying
NOTE: Conflicts between +W, +Ww and +We options are resolved based on the severity. The +We option is the highest and +W is the lowest.
Following is the syntax for disabling warnings in a macro.
$cadvise +wall
Following is an example for disabling warnings in a macro.
Example 19 Disabling warnings in a macro
$cadvise +wall
5.6 Managing warnings in a source file
#pragma diag_suppress diag_warning diag_error NNNN #pragma diag_default NNNN
Command line options help you to generate diagnostic messages for the entire build or for a specific source file. There are several pragmas available to manage warnings for a specific region within a source file. The use of #pragma diag_suppress within the source code disables generation of warning N after the pragma in the source file. The pragma diag_default restores the default handling for the diagnostic message N. Similarly, diag_warning enables generation of a diagnostic message and diag_error converts a warning to an error. The following example disables warning
Example 20 Disabling a warning locally
int i;
#pragma diag_suppress 2549 printf ("i = %d\n", i); #pragma diag_default 2549
NOTE: These pragmas are not applicable to warning numbers greater than 20000.
26 Configuring diagnostic messages