Portable UNUSED parameter macro used on function signature for C and C++

前端 未结 4 450
终归单人心
终归单人心 2020-11-30 02:20

I\'m interested in creating a macro for eliminating the unused variable warning.

This question describes a way to suppress the unused parameter warning by writing a

4条回答
  •  渐次进展
    2020-11-30 02:47

    Just one small thing, better using __attribute__((__unused__)) as __attribute__((unused)), because unused could be somewhere defined as macro, personally I had a few issues with this situation.

    But the trick I'm using is, which I found more readable is:

    #define UNUSED(x) (void)x;

    It works however only for the variables, and arguments of the methods, but not for the function itself.

提交回复
热议问题