更新时间:2022-10-15 17:21:41
也会遇到这种烦恼。根据GCC手册页 -Wall
为您打开 -Wunknown-pragmas
,因此只需手动使用 -Wno-unknown-pragmas
-Wall
I try to ignore warnings coming from some 3rd party header files like this:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wreorder"
#include <some_3rd_party_header.h>
#pragma GCC diagnostic pop
This approach seems to work in general, but not for the unknown pragma warnings (I still get them).
Why does it work for other warnings but not for this one? Can anyone confirm this behaviour?
I'm using g++ (version 4.7.1) with -Wall
and -std=c++0x
under Debian.
I've run into this annoyance, too. According to the GCC manpage -Wall
turns on -Wunknown-pragmas
for you, so just manually disable it using -Wno-unknown-pragmas
after -Wall