views:

295

answers:

2

I am tired of having to look at warnings during our compilations - warnings that come from MS include files.

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\mmsystem.h(1840): warning C4201: nonstandard extension used : nameless struct/union"

I have seen this thread that suggests changing the header itself (but then each of my team mates has to do it and we have to do it on the build server - not to mention it is a glorious HACK)

Is there a better way? I don't want to turn it off globally - just to suppress it for certain files or directories.

Any suggestions?

EDIT For some stupid reason I didn't think I could set warning levels across include files. Thanks - that does the trick.

+6  A: 

Something like

#pragma warning(push, disable: 1840)
#include <mmsystem.h>
#pragma warning(pop)

? (Not sure about the exact syntax.)

sbi
(+1) wasn't aware you could do the push, disable in the one line :)
Alex Deem
When dealing with 3rd party software, WRAP.
Matthieu M.
+2  A: 

How about using #pragma warning extension in VC++?

http://msdn.microsoft.com/en-us/library/2c8f766e%28VS.80%29.aspx

#pragma warning (push, 2)  // Temporarily setting warning level 2
#include <mmsystem.h>
#pragma warning (pop)      // Restore back

You may also try ..

#pragma warning (disable: 4201)
#include <mmsystem.h>
#pragma warning (default)
minjang
I don't want to reduce the warning level - I just want to suppress a particular one, but I managed to figure it out.
Tim
But, only for system headers. It's okay to reduce warning level for such system header, that you don't want to modify the source code.
minjang