In the function:
void DoSomething(int a, int b) {
SomeOtherFunction(a); }
The compiler (C166) generates the warning unused parameter b. So I tried:
b;
And get warning expression with possibly no effect. So I tried:
void DoSomething(int a, int /*b*/) {
And got warning non standard extension - unnamed parameter!
Anybody got any other ideas?
I have found that works with several compilers:
if (b);
If you want the code to be protable between compilers, you might want to wrap the 'silencing' code by a macro:
#define UNUSED_ARG(x) do { if (x) ; } while (0) /* or whatever */
Besides, it will probably make the code more readable.
I think that the conclusion from this thread is that the solution is not portable - because what "works" on one compiler may not on another.
To make it "portable", you'd need comditional-compilation to select the appropriate construct for the particular compiler...
But the technique of wrapping an "executable" macro in do{...}while(0) is a common one:
c-faq.com/.../multistmt.html