GCC warnings at all levels
Overwrite from top to bottom
Variable (code) level: Specify a variable warning
int a __attribute__ ((unused));
Specifies that the variable is unused. Even if the variable is not used, a warning output is ignored at compile time.
FILE-level: diagnostics (Ignore/warn) in source code files
Grammar:
#pragma GCC diagnostic [error|warning|ignored] "-w< warning Options >"
Diagnostics-Ignore: (Turn off warning)
#pragma GCC diagnostic ignored "-wunused"
#pragma GCC diagnostic ignored "-wunused-parameter"
Diagnostics-Warning: (Turn on warning)
#pragma GCC diagnostic warning "-wunused"
#pragma GCC diagnostic warning "-wunused-parameter"
Diagnostics-Error: (Turn on warning-upgrade to error)
#pragma GCC diagnostic error "-wunused"
#pragma GCC diagnostic error "-wunused-parameter"
Usage:
Close the warning at the beginning of the file, and then turn on the warning at the end of the file to ignore the specified warning in the file.
Project-level: command line/compile parameters specified
Warning:
GCC Main.c-wall ignored:
GCC Mian.c-wall-wno-unused-parameter//Open all warning, but ignore-unused-parameter warning
Option format:-w[no-]< warning Options >
such as:-wno-unused-parameter # no-indicates that this warning is ignored when diagnosing
Compiler handles warnings, errors #pragma GCC diagnostic ignored "-wunused"