charlesg
charlesg

Reputation: 1

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.

Upvotes: 0

Views: 331

Answers (1)

EvilTeach
EvilTeach

Reputation: 28882

You can achieve the same effect by simply setting it in your project. (properties)(c++)(general) set treat warnings as errors to Y. Your cohorts leave it at 'N'.

Note that I am assuming that each developer has their own project setup.

Upvotes: 1

Related Questions