“未使用的参数” C中的警告 [英] "unused parameter" warnings in C
本文介绍了“未使用的参数” C中的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,
$
$ b返回TRUE; bool NullFunc(const struct timespec * when,const char * who)
{
return TRUE;
}
在C ++我能够把一个 / * ... * /
注释围绕参数。但当然不是C语言。
它给了我的错误:参数名省略
。
解决方案
我通常写这样一个宏:
#定义未使用(X)(无效)(X)
您可以使用此宏为您所有的未使用的参数。 (请注意,这适用于任何编译器。)
例如:
void f(int x){
UNUSED(x);
...
}
What's the best way to suppress unused parameter warning in C code.
For instance,
Bool NullFunc(const struct timespec *when, const char *who)
{
return TRUE;
}
In C++ I was able to put a /*...*/
comment around the parameters. But not in C of course.
It gives me error: parameter name omitted
.
解决方案
I usually write a macro like this:
#define UNUSED(x) (void)(x)
You can use this macro for all your unused parameters. (Note that this works on any compiler.)
For example:
void f(int x) {
UNUSED(x);
...
}
这篇关于“未使用的参数” C中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文