抑制GCC中的-Wunknown-pragmas警告 [英] Suppress -Wunknown-pragmas warning in GCC

查看:6040
本文介绍了抑制GCC中的-Wunknown-pragmas警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试忽略来自像这样的第三方头文件的警告:

  #pragma GCC诊断推送
#pragma GCC诊断忽略-Wunknown-pragmas
#pragma忽略GCC诊断-Wreorder

#include

#pragma GCC诊断弹出

这种方法似乎可以工作在一般情况下,但不是未知的编译指示警告(我仍然得到它们)。

为什么它可以用于其他警告,但不适用于这个警告?任何人都可以证实这种行为?



我使用g ++(版本4.7.1)和 -Wall -std = c ++ 0x 在Debian下。

解决方案

也会遇到这种烦恼。根据GCC手册页 -Wall 为您打开 -Wunknown-pragmas ,因此只需手动使用 -Wno-unknown-pragmas -Wall

后的

I try to ignore warnings coming from some 3rd party header files like this:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wreorder"

#include <some_3rd_party_header.h>

#pragma GCC diagnostic pop

This approach seems to work in general, but not for the unknown pragma warnings (I still get them).

Why does it work for other warnings but not for this one? Can anyone confirm this behaviour?

I'm using g++ (version 4.7.1) with -Wall and -std=c++0x under Debian.

解决方案

I've run into this annoyance, too. According to the GCC manpage -Wall turns on -Wunknown-pragmas for you, so just manually disable it using -Wno-unknown-pragmas after -Wall

这篇关于抑制GCC中的-Wunknown-pragmas警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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