如何抑制“未使用的参数"?警告在C? [英] How to suppress "unused parameter" warnings in C?
本文介绍了如何抑制“未使用的参数"?警告在C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
Bool NullFunc(const struct timespec *when, const char *who)
{
return TRUE;
}
在C ++中,我可以在参数周围添加/*...*/
注释.但是,当然不是在C中,它会给我错误error: parameter name omitted
.
In C++ I was able to put a /*...*/
comment around the parameters. But not in C of course, where it gives me the error 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.)
例如:
void f(int x) {
UNUSED(x);
...
}
这篇关于如何抑制“未使用的参数"?警告在C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文