我有代码:
#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/