remove 'NOTUSED' macro?
While reviewing !2450 (merged), I recalled the Graphviz tree has various NOTUSED
macros:
#define NOTUSED(x) (void) (x)
This is wrapping the common idiom for squashing warnings for unused parameters. However, it is used inconsistently in the code base. Thus Graphviz developers still need to know and recognize this idiom when they see it.
Should we remove these macros and write (void)x;
wherever we are ignoring x
? My thinking is that only two end states make sense: (1) NOTUSED
used everywhere, or (2) NOTUSED
used nowhere and removed. Which should we move towards?
CC @magjac, @makelinux
Some elaborating discussion for completeness...
There is a GCC extension for squashing such warnings:
void foo(int x __attribute__((unused))) {
}
This GNU attribute is also supported by Clang. In C++, there is a much nicer portable way of expressing this by omitting the parameter name:
void foo(int) {
}
There has been some discussion over the years of bringing attribute syntax to ISO C. C++11 introduced [[...]]
syntax for attributes and I have some hope this will come to a future version of ISO C. However I am not aware of any plans for this right now.
So a void cast is the most portable way I'm currently aware of for suppressing such warnings in C.