For example, you can suppress a particular diagnostic message when compiling one specific
You can also use options to suppress or change the severity of messages, but the change
applies for the entire compilation.
Diagnostic messages use the pragma state in place at the time they are generated. If you
use pragmas to control a message in your code, you must be aware of when that message is
generated. For example, the following code is intended to suppress the diagnostic message
177 (“Function was declared but never referenced”) for the
#pragma diag_suppress 177
static int dummy(void)
printf("This function is never called.");
The intention of the programmer is to push the current pragma state to the stack, suppress
diagnostic message 177 when compiling the
dummy function, then restore the
original pragma state before continuing with compilation.
However, message 177 is only generated after all functions have been processed. Therefore,
the message is generated after
pragma pop restores the pragma state, and
message 177 is not suppressed.
pragma push and
pragma pop would correctly
suppress message 177, but would suppress messages for all unreferenced functions rather than