I have enabled -Werror for C pre processing command to treat warnings as errors.
Basically i wanted to only treat redefined warnings as errors. And all other warnings should not be treated as errors.
In file included from /home/test/version24/test.spec:35:0,
/test/release/base_version.spec:93:0: warning: "CD_MK_FILE" redefined
#define CD_MK_FILE 4
In file included from /home/test/version23/mss_litter.spec:19:0,
from
/test/release/base_version23.spec:0: note: this is the location of the previous definition
#define CD_MK_FILE 3
Is there any flag in to treat only redefined warnings as errors. Thank you!
How to only treat macro-redefined warnings as errors, and let all other warnings not be treated as errors:
-Werror=macro-redefined.For gcc/g++ and clang compilers, try:
# To disable -Werror just for warning -Wwhatever
-Wno-error=whatever
# To **enable** errors just for this one -Wwhatever warning
-Werror=whatever
For the clang compiler, you'd use -Wno-error=macro-redefined, to disable that error for the -Wmacro-redefined warning only, and you'd use -Werror=macro-redefined to enable an error only for that warning.
See here: https://clang.llvm.org/docs/DiagnosticsReference.html#wmacro-redefined. Thanks for the comment under the question, @user3386109!
See the list of all possible warnings and errors here:
For example, from the gcc link above:
-Werror=Make the specified warning into an error. The specifier for a warning is appended; for example
-Werror=switchturns the warnings controlled by-Wswitchinto errors. This switch takes a negative form, to be used to negate-Werrorfor specific warnings; for example-Wno-error=switchmakes-Wswitchwarnings not be errors, even when-Werroris in effect.The warning message for each controllable warning includes the option that controls the warning. That option can then be used with
-Werror=and-Wno-error=as described above. (Printing of the option in the warning message can be disabled using the-fno-diagnostics-show-optionflag.)Note that specifying
-Werror=fooautomatically implies-Wfoo. However,-Wno-error=foodoes not imply anything.
-Werror build error in Bazel? (AKA: how to turn OFF specific warnings already turned on by -Wall -Werror)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With