有什么办法禁用所有警告用pragma在clang或gcc? [英] Is there any way to disable all warnings with a pragma in clang or gcc?

查看:309
本文介绍了有什么办法禁用所有警告用pragma在clang或gcc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GCC和clang让你用-w编译来禁用所有的警告,但我看不到#pragma的等效。我只能看到禁用单个文件的pragma支持。



我需要这个,因为我有一个代码,我想编译高警告级别,但必须编译第三方代码,生成任意警告。

$ b $您可以使用 使用GCC进行修改 #pragma GCC diagnostic ignored code>,但不幸的是不太好,请参见此处



问题是,你不能只是禁用所有,你必须禁用每个单一的。此外,对于一些警告,它不工作(和文档不告诉你哪些...)。



我的猜测是,这有点初步,将(希望)在下一版本中得到改进。


GCC and clang let you compile with -w to disable all warnings, but I can't see a #pragma equivalent of it. I can see only pragma support for disabling individual files.

I need this because I have code that I want to compile with high warning levels but which necessarily compiles third party code which generates arbitrary warnings.

解决方案

You can kind of do it with GCC, almost, using #pragma GCC diagnostic ignored, but unluckily not very well, see here.

The problem is that you cannot just "disable all", you have to disable each single one. Plus, for some warnings it doesn't work (and the docs don't tell you which ones...).

My guess is that this somewhat preliminary and will (hopefully) be improved in the next version.

这篇关于有什么办法禁用所有警告用pragma在clang或gcc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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