5

In my codebase, I have an include file (MyBaseDefinitions.h) that does a pragma diagnostic push followed by disabling a lot of warnings. If you want to re-enable those warnings, you simply include another header afterwards that does pragma diagnostic pop (EndMyBaseDefinitions.h).

This seems to work fine except on Clang when putting MyBaseDefinitions.h in the precompiled header. It appears that the diagnostic 'stack' is lost when it's in a precompiled header. So let's say I have MyPrecompiledHeader.h and it has:

#include "MyBaseDefinitions.h" // does the pragma diagnostic push

And then in my demo file I do:

#include "MyPrecompiledHeader.h"

#include "HeaderExample1.h" // This file has some warnings in it that we don't care about
#include "EndMyBaseDefinitions.h" // Re-enable warnings

// ... 

I'll get a warning:

error : pragma diagnostic pop could not pop, no matching push [-Werror,-Wunknown-pragmas]

Is this a known issue? Obviously ideally I wouldn't have to do any warning disabling at all, but let's try to ignore that detail for now if possible.

--Joel

jvaneenwyk
  • 73
  • 1
  • 5

0 Answers0