Go to the first, previous, next, last section, table of contents.

How to silence "unused parameter" warnings

"When I use -Wall (or -Wunused), g++ warns about unused parameters. But the parameters have to be there, for use in derived class functions. How do I get g++ to stop complaining?"

The answer is to simply omit the names of the unused parameters when defining the function. This makes clear, both to g++ and to readers of your code, that the parameter is unused. For example:

int Foo::bar(int arg) { return 0; }

will give a warning for the unused parameter arg. To suppress the warning write

int Foo::bar(int) { return 0; }

Go to the first, previous, next, last section, table of contents.