Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing a Dummy Statement

Tags:

c++

unix

gcc

In my current program I have a function already defined as

void functionName( const customClass object );

Now, in the code for this function, this object is not used. I don't have permission to to remove the parameter, nor can I remove the unused parameter warning.

Is there a statement I can execute with this object (customClass doesn't have any functions which I can run here), so that this warning doesn't happen?

like image 224
Parag Gupta Avatar asked Nov 25 '25 11:11

Parag Gupta


2 Answers

You can remove the name of the parameter from the definition:

void functionName( const customClass );

This doesn't change the signature of the function (it's compatible with your existing declaration), but since the variable isn't named there won't be an unused parameter warning.

like image 175
DRH Avatar answered Nov 28 '25 01:11

DRH


Common way to do this is

void functionName(const customClass object)
{
    (void)object; // gets rid of warning
}
like image 44
Suma Avatar answered Nov 28 '25 02:11

Suma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!