How to suppress specific warnings in g++(如何抑制 g++ 中的特定警告)
问题描述
我想禁止来自 g++ 的特定警告.我知道 -Wno-XXX
标志,但我正在寻找更具体的东西.我想要-Weffc++
中的一些 警告,但不是全部.类似于您可以使用 lint 执行的操作 - 禁用特定消息.
I want to suppress specific warnings from g++. I'm aware of the -Wno-XXX
flag, but I'm looking for something more specific. I want some of the warnings in -Weffc++
, but not all of them. Something like what you can do with lint - disable specific messages.
gcc 中是否有内置方法可以做到这一点?我必须编写包装脚本吗?
Is there a built in way in gcc to do this? Do I have to write a wrapper script?
推荐答案
很遗憾,g++ 没有提供这个功能. 在 VC++ 中,你可以使用 #pragma warning 禁用某些特定警告.在 gcc 中,您可以拥有的最接近的是 diagnostic pragmas,它让您为某些文件或项目启用/禁用某些类型的诊断.
Unfortunately, this feature isn't provided by g++. In VC++, you could use #pragma warning to disable some specific warnings. In gcc, the closest you can have is diagnostic pragmas, which let you enable/disable certain types of diagnostics for certain files or projects.
编辑:GCC 从 4.6.4 开始支持推送/弹出警告(参见 更改日志)
Edit: GCC supports pushing/popping warnings since 4.6.4 (see changelog)
这篇关于如何抑制 g++ 中的特定警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何抑制 g++ 中的特定警告


基础教程推荐
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- C++,'if' 表达式中的变量声明 2021-01-01
- 设计字符串本地化的最佳方法 2022-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01