In C, unlike C++, all parameters to a function definition must be named.
Instead of quashing "unused parameter" errors with (void)a
, or openly using __attribute__((unused))
, I've created the following macro:
#define UNUSED2(var, uniq) UNUSED_ ## line ## var __attribute((unused))
// squash unused variable warnings, can it be done without var?
#define UNUSED(var) UNUSED2(var, __func__)
Used like this
void blah(char const *UNUSED(path)) {}
Is there some way I can guarantee a unique "dummy" variable name (obviously LINE
and __func__
can't cut it), or neglect to name the unused variables at all?
Update0
The final code used is available here. It's used like this:
void blah(char const *UNUSED) {}
And avoids both unused parameter, unnamed parameter warnings, and guarantees that it's not going to clobber some other variable name.