My project uses -Werror
to turn GCC 11.3.0 g++ warnings to errors and stop the build. But a 3rd party header file we need to include causes a bunch of warnings to be issued by the compiler.
I was hoping there is a way to turn off -Werror
for that 1 include file. Maybe a #pragma
I can issue just before and just after that header file is invoked?
However, it does not seem to be the case. Best I can find is to disable individual warnings with #pragma GCC diagnostic ...
, which would make me list all of the warnings that this header file causes.
Is that really the case or did I miss something obvious?
Edit:
Turns out some warnings/errors can be disabled, but others cannot. For example, this works to remove the signed/unsigned warnings:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <problematic_include.hpp>
#pragma GCC diagnostic pop
But this does not work:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#include <problematic_include.hpp>
#pragma GCC diagnostic pop
...to remove the error about error: ignoring ‘#pragma _CVUI_COMPILE_MESSAGE ’ [-Werror=unknown-pragmas]
.