Using pragma push in a precompiled header with Clang without pop

In my code base, I have an include file ( MyBaseDefinitions.h ) that does a pragma diagnostic push and then disables a lot of warnings. If you want to re-enable these warnings, you simply include one more heading that pragma diagnostic pop does ( EndMyBaseDefinitions.h ).

This seems to work just fine, with the exception of Clang, when placing MyBaseDefinitions.h in a precompiled header. It appears that the diagnostic β€œstack” is lost when it is in a precompiled header. So let's say that I have MyPrecompiledHeader.h and it has:

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

And here in my demo file I:

 #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 will get a warning:

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

Is this a known issue? Obviously, ideally, I would not need to turn off the warning altogether, but try to ignore this detail if possible.

- Joel

+5
source share

Source: https://habr.com/ru/post/1270173/


All Articles