禁用gcc中的特定警告 [英] disable specific warnings in gcc

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

问题描述

在Microsoft编译器上,可以使用#pragma禁用特定警告,而不禁用其他警告。这是一个非常有用的功能,如果编译器警告必须完成的事情。

On microsoft compilers, specific warnings can be disabled with a #pragma, without disabling other warnings. This is an extremely useful feature if the compiler warns over something that "has to be done".

GCC在这一点上是否有类似的功能?这似乎是一个足够明显的功能,它无法想象,它不会有这个功能,但在网络上的旧信息表明这个功能不存在。

Does GCC at this point have a similar feature? It seems like an obvious enough feature that its unimaginable that it wouldn't have this feature yet, but older info on the web suggests this feature doesn't exist.

什么是在GCC中使用的吗?

What is one to use in GCC?

具体而言,我喜欢使用多字符常量,如'abc'。这些数据可以有效地评估为基本256位数 - 这是一个非常方便的功能,但会触发警告。它非常方便在一个case语句中切换四个字符串。

Specifically, I like to use multi-character constants, like 'abc'. These evaluate effectively as a base 256 number - a very handy feature, but it triggers a warning. Its very handy for switching on four character strings in a case statement.

推荐答案

这可以通过gcc的 diagnostic pragmas

这篇关于禁用gcc中的特定警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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