禁用一个未使用的变量警告 [英] Disable one unused variable warning

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

问题描述

如何仅在一个地方禁用一项警告?

How can I disable one warning in one place only?

我有一个暂时不使用的变量。 Xcode向我显示了有关未使用的变量的警告。我想禁用警告,但仅禁用此变量,而不是所有此类警告。

I have one variable which I temporarily don't use. Xcode shows me a warning about the "unused variable". I want to disable the warning, but for this variable only, not all warnings of this type.

是否可以不设置/获取此变量的值?

Is it possible without setting/getting this variable's value?

推荐答案

来自 GCC /指定变量属性(也由Clang理解):

From GCC / Specifying Attributes of Variables (understood by Clang as well):

int x __attribute__ ((unused));

int y __attribute__((unused)) = initialValue ;

这篇关于禁用一个未使用的变量警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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