如何抑制来自库头文件的 GCC 警告? [英] How to suppress GCC warnings from library headers?
问题描述
我有一个使用 log4cxx、boost 等库的项目,其头文件会生成大量(重复)警告.有没有办法抑制来自库包含的警告(即#include
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.
推荐答案
您可以尝试使用 -isystem
而不是 -I
来包含库头文件.这将使它们成为系统标头"并且 GCC 不会为它们报告警告.
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.
这篇关于如何抑制来自库头文件的 GCC 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!