什么是苏preSS&QUOT的最佳途径;未使用的变量x" -warning [英] What is the best way to supress "Unused variable x"-warning

查看:143
本文介绍了什么是苏preSS&QUOT的最佳途径;未使用的变量x" -warning的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是燮preSS编译器(在这种情况下,海湾合作委员会),如未使用变量x-warning最好/最巧妙的方法?

What is the best/neatest way to suppress a compiler (in this case gcc) like "Unused variable x"-warning?

我不希望给任何特定的标志,以GCC删除所有这些警告,只在特殊情况下。

I don't want to give any certain flags to gcc to remove all these warnings, just for special cases.

推荐答案

找到一篇文章<一个href=\"http://sourcefrog.net/weblog/software/languages/C/unused.html\">http://sourcefrog.net/weblog/software/languages/C/unused.html解释未使用。有趣的是,笔者还轧液未使用的变量名,所以你不能在不经意间在将来使用它。

Found an article http://sourcefrog.net/weblog/software/languages/C/unused.html that explains UNUSED. Interesting that the author also mangles the unused variable name so you can't inadvertently use it in the future.

摘录:

#ifdef UNUSED
#elif defined(__GNUC__)
# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
#elif defined(__LCLINT__)
# define UNUSED(x) /*@unused@*/ x
#else
# define UNUSED(x) x
#endif

void dcc_mon_siginfo_handler(int UNUSED(whatsig)) 

这篇关于什么是苏preSS&QUOT的最佳途径;未使用的变量x&QUOT; -warning的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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