How to suppress GCC warnings from library headers?

2019-01-02 20:07发布

I have a project that uses log4cxx, boost, etc. libraries whose headers generate lots of (repetitive) warnings. Is there a way to suppress warnings from library includes (i.e. #include <some-header.h>) or includes from certain paths? I'd like to use -Wall and/or -Wextra as usual on project code without relevant info being obscured. I currently use grep on make output but I'd like something better.

8条回答
看风景的人
2楼-- · 2019-01-02 20:49

I found the trick. For library includes, instead of -Idir use -isystem dir in the makefile. GCC then treats boost etc. as system includes and ignores any warnings from them.

查看更多
呛了眼睛熬了心
3楼-- · 2019-01-02 20:56

You may try to include library headers using -isystem instead of -I. This will make them "system headers" and GCC won't report warnings for them.

查看更多
登录 后发表回答