用C code未使用的参数警告 [英] unused parameter warnings in C code
本文介绍了用C code未使用的参数警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是燮用C code preSS未使用的参数警告的最佳方式。
What's the best way to suppress "unused parameter" warning in C code.
例如,
Bool NullFunc(const struct timespec *when, const char *who, unsigned short format, void *data, int len)
{
return TRUE;
}
在C ++中,我能够把 /*...*/
注释周围的参数。但不是在当然℃。
In C++ I was able to put a /*...*/
comment around the parameters. But not in C of course.
这给了我错误:参数名省略
一些技巧将AP preciated。
Some tips would be appreciated.
推荐答案
我平时写这样的宏:
#define UNUSED(x) (void)(x)
您可以使用此宏为您的所有未使用的参数。 (请注意,这适用于任何编译器。)
You can use this macro for all your unused parameters. (Note that this works on any compiler.)
例如:
void f(int x) {
UNUSED(x);
...
}
这篇关于用C code未使用的参数警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文