I would like to enable Warning as Error on our current project/solution for obvious reasons.
There are several warnings that should NOT be handled as an error, eg Obsolete, and using #warning directives.
Is this possible?
I see that I can make specific warnings behave as errors, but I would really like the 'invert' of that.
The closest I can get is disabling the 2 above mentioned warnings, but then there will be no 'warning' for them either.
Any suggestions?
To clarify:
I want the warnings, just not as an error. So all warning except for the above mentioned exceptions will behave as an error, and the above mentioned will be warnings (ones I can see in the compiler results).
Yes, even once in a while you will encounter the occasional warning you'd be better off leaving as a warning or even disabling completely. Those should be the exception to the rule, though. Here's some practical advise: at the start of a new project, start treating all warnings as errors, by default.
WARNING: Something has not worked as it should. This may be of greater or lesser importance depending on the circumstances. e.g. An input file was not found, or was of the wrong format. ERROR: Something ``serious'' has gone wrong.
You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).
TreatWarningsAsErrors. The TreatWarningsAsErrors option treats all warnings as errors. You can also use the TreatWarningsAsErrors to set only some warnings as errors. If you turn on TreatWarningsAsErrors, you can use WarningsNotAsErrors to list warnings that shouldn't be treated as errors.
The warnaserror
compiler option supports erroring only on specific warnings. You can thus specify all warnings to be shown as an error, then disable the errors for certain warnings. Using the page's example as a guide:
/warnaserror
/warnaserror-:642,649,652
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