This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get rid of unused parameter warnings?

In the function:

void DoSomething(int a, int b)
{

SomeOtherFunction(a);
}

The compiler (C166) generates the warning unused parameter b. So I tried:

void DoSomething(int a, int b)
{

b;

SomeOtherFunction(a);
}

And get warning expression with possibly no effect. So I tried:

void DoSomething(int a, int /*b*/)
{

SomeOtherFunction(a);
}

And got warning non standard extension - unnamed parameter!

Anybody got any other ideas?

Parents
  • Wow, I didn't expect so many helpful replies. Thanks for all the good advice. I also tried the if(b); option but it gives an expression has no effect warning. So, the conclusion seems to be that disabling the warning is the only option.

    If it did work I would definitely think an unused() macro would be the way to go.

    I don't really like to remove the warning as it has saved me before from doing something done and is good for pointing out potential design issues in your code. I guess I can live with it for now fortunately they are in modules that are rarely recompiled.

    Thanks for all the advice...

Reply
  • Wow, I didn't expect so many helpful replies. Thanks for all the good advice. I also tried the if(b); option but it gives an expression has no effect warning. So, the conclusion seems to be that disabling the warning is the only option.

    If it did work I would definitely think an unused() macro would be the way to go.

    I don't really like to remove the warning as it has saved me before from doing something done and is good for pointing out potential design issues in your code. I guess I can live with it for now fortunately they are in modules that are rarely recompiled.

    Thanks for all the advice...

Children
  • I don't really like to remove the warning as it has saved me before from doing something

    I have to agree here. There should be a possibility to mark a singular parameter. I definitely want a warning like this in general. But I want to turn it off if I keep a parameter to conform with a certain interface.

    Lints /* ARGSUSEDn */ comes to mind.