如何抑制来自库头文件的 GCC 警告? [英] How to suppress GCC warnings from library headers?

查看:51
本文介绍了如何抑制来自库头文件的 GCC 警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 log4cxx、boost 等库的项目,其头文件会生成大量(重复)警告.有没有办法抑制来自库包含的警告(即#include )或来自某些路径的包含?我想像往常一样在项目代码上使用 -Wall 和/或 -Wextra,而不会掩盖相关信息.我目前在 make 输出上使用 grep,但我想要更好的东西.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆