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
  • This is an old chestnut - it comes up again and again!

    Some compilers are thoughtful enough to provide some kind of #pragma or similar to handle this.

    Otherwise, it's a matter of finding some bening bit of code that doesn't then give some other warning - as you've found...

    Have you tried

    void DoSomething(int a, int b)
    {
    
       b=b;
    }
    

Reply
  • This is an old chestnut - it comes up again and again!

    Some compilers are thoughtful enough to provide some kind of #pragma or similar to handle this.

    Otherwise, it's a matter of finding some bening bit of code that doesn't then give some other warning - as you've found...

    Have you tried

    void DoSomething(int a, int b)
    {
    
       b=b;
    }
    

Children