'Is there an option to turn on "warnings as errors" programmatically in C++ in Visual Studio?
I would like to turn on the "warnings as errors" feature for just me, but not other programmers who share the same code. I can use a macro like #ifdef MY_VERSION to limit this.
However, I can't see a way to turn on this feature (the /WX compiler switch) inside of the code.
Or alternatively, to set a range of warnings as errors, e.g. something like #pragma warning (error: 4000-4999) which would let me set this for just me but noone else.
Or possibly some other way to ensure that when code with MY_VERSION defined is built, warnings are treated as errors, but when it isn't defined, they aren't.
I've tried to find something in the MS docs, but haven't managed to do so. There may be something involving the "Project Engine", but if so I don't understand how to go about it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
