Question

I'm currently having an issue using a third party library that has broken pragmas that are pushing a lot of disabled warnings without correctly popping them so they stay disabled forever. I want the warnings to be enabled in order to detect any problems in my code that is including the third party files. Since modifying the third party source should be a last resort I'd like to know if there are any other options to fix this.

The only thing I can think of is to manually add #pragma warning (pop) calls until the warnings start showing up again, but that seems really dirty. Is there some easy way to just pop everything that has been pushed all at once with a single call or something? If that's not an option, are there any other solutions to this problem other than trying to figure out how to fix the broken pragmas in the third party source? The third party source is very complicated so fixing it there wouldn't be easy.

EDIT: It seems like there's no real solution for this other than fixing the third party code so I guess I'll just work with the dirty solution of adding a bunch of #pragma warning (pop) statements in the files being worked on to make sure the warnings are enabled. It sucks, a lot, but I don't have the time to fix the third party code so it'll have to do for now...I'll leave this open for a couple days and if no better solution comes up then I'll close it out somehow.

Was it helpful?

Solution 2

It looks like the only solution to this problem is to either fix the bug in the third party code or to manually add #pragma warning(pop) multiple times after including the third party files until the warnings start showing up. For me, I had to add that line four times.

Both of these options suck but so far there's no other way around it.

OTHER TIPS

If I'm reading this correctly, you should be able to do:

#pragma warning( push )

#include "offending_lib.h"

#pragma warning( pop ) 

I suggest to write a wrapper to that 3rd party library, so that only the warpper suffer from muted warnings.

As a side effect, you also benefit by minimizing risk when the library changes, or even when you decide to switch to other library.

Anyway, if you are using VC you may reset warning behaviour with:

#pragma warning(default)

Reference: http://msdn.microsoft.com/en-us/library/2c8f766e.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top