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, where it gives me the error error: parameter name omitted
.
With gcc with the unused attribute:
I got the same problem. I used a third-part library. When I compile this library, the compiler (gcc/clang) will complain about unused variables.
Like this
So the solution is pretty clear. Adding
-Wno-unused
as gcc/clang CFLAG will suppress all "unused" warnings, even thought you have-Wall
set.In this way, you DO NOT NEED to change any code.
I usually write a macro like this:
You can use this macro for all your unused parameters. (Note that this works on any compiler.)
For example:
Seeing that this is marked as gcc you can use the command line switch
Wno-unused-parameter
.For example:
Of course this effects the whole file (and maybe project depending where you set the switch) but you don't have to change any code.
In gcc, you can label the parameter with the
unused
attribute.In practice this is accomplished by putting
__attribute__ ((unused))
just before the parameter. For example:becomes