c++ - 抑制 GCC 警告

标签 c++ gcc gcc-warning

我有代码:

#ifdef Q_OS_LINUX
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcomment"
#include "header.h"
#pragma GCC diagnostic pop
#endif

而且我想禁止与 header.h 和 header.h 中包含的所有 header 相关的 GCC 警告消息。但我仍然收到与 header.h 中包含的 header 相关的“-Wcomment”警告。我怎样才能避免这种情况?谢谢

海湾合作委员会 4.8.2

编辑: 我收到的警告如下所示:

/------ Set Analog Output for 8022/8026 --------- /Exp8K WORD CALLBACK AnalogOutHex_8K(DWORD dwBuf[], float fBuf[], warning: "/" within comment [-Wcomment] No other pragmas surely. -Wall doesn't work

最佳答案

如果你可以修改header.h,你可以将它定义为system header使用 #pragma GCC system_header。否则,您可以使用 -isystem 将其添加到 gcc 命令行。

All warnings, other than those generated by ‘#warning’ (see Diagnostics), are suppressed while GCC is processing a system header.

关于c++ - 抑制 GCC 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23193914/

相关文章:

c++ - 读取与忽略的不同 EOF 行为

c++ - 从数据库中选择客户信息并存储到 vector 中

c++ - "vector iterators incompatible"使用 swap-and-pop 迭代时删除 vector 中的元素断言失败

c - 汇编循环遍历字符串来计算字符数

c - 为什么 "1 ? (int*)1 : ((void*)((x) * 0l))"可以正常工作?

c++ - 关于-Waggregate-return 的目的/行为的混淆?

c++ - cpp 中的并行 memcpy

c++ - 为什么 GNU ld 在内存中留下一个洞?

c - C中二维数组的内存运行时错误

c++ - C中的&&&&操作是什么