G ++: how to disable a specific "obsolete or obsolete header"?

We are using g ++ 4.4.3, and one of our third-party libraries is causing an excellent error.

/usr/include/++/4.4/backward/backward_warning.h: 28: 2: warning: #warning This file contains at least one obsolete or obsolete header, which may be deleted without further notice in the future. Instead, use a non-legacy interface with equivalent functionality. For a list of replacement headers and interfaces, refer to the backward_warning.h file. To disable this warning, use -Wno-deprecated.

Since this is a third-party library, I cannot fix this problem, so I just want to tell the compiler to suppress this warning for a single H file that causes the problem.

I tried a few things with

#pragma GCC diagnostic ignored "-Wdeprecated" 

but I can’t find which warning to indicate (no "-Wdeprecated").

How can I suppress this warning for only one offensive file H? I hope to do something like this:

 // Turn off the warning #pragma GCC diagnostic ignored "-Wdeprecated" #include "BadFile.h" // Turn the warning back on #pragma GCC diagnostic warning "-Wdeprecated" 
+4
source share
1 answer

I could not figure out how to do this using pragma, only by passing -Wno-deprecated on the command line. Therefore, if you are desperate, you can try:

 #undef __DEPRECATED // include offensive headers here... #define __DEPRECATED 

But note that I definitely do not recommend undef'ing the system level #defines :-P

0
source

All Articles