user1101674
user1101674

Reputation: 1421

How to configure Visual Studio not to output warnings from libraries?

Is there any way to prevent Visual Studio from printing out warnings from included libraries?

\Wall gives me loads of warnings from STL and Qt headers, although I only want to see those originating from my own code (i.e. the code which is part of the current Visual Studio project).

Upvotes: 1

Views: 1676

Answers (2)

Trass3r
Trass3r

Reputation: 6297

That's the only portable way (if using -isystem with other compilers):

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: ...)
#endif
#include <Q...>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

Hopefully they will implement isystem one of these days:

https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/14717934-add-a-cl-exe-option-for-system-headers-like-gcc-s

Upvotes: 0

RedX
RedX

Reputation: 15184

You can use pragma to set the warning levels for each file.

So before you include

#pragma warning( push )
#pragma warning( disable : 4705 )
#pragma warning( disable : 4706 )
#pragma warning( disable : 4707 )
// Some code

#include your files here

#pragma warning( pop ) 

More information here: http://msdn.microsoft.com/en-us/library/2c8f766e%28v=vs.80%29.aspx

Upvotes: 4

Related Questions