I just saw a guy did this today when I was studying his code fragment:
void doSomething(int param) {
// stuffs
param; // <-- what does this statement do?
// stuffs
}
I tried looking for it on the internet and asked most of my friends about it but this one looks alien to them too. So guys, what does that statement do really?
It may serve to remove a warning about unused parameters. But logically it does nothing. There are better ways to remove the warning about an unused parameter. Using a macro:
UNREFERENCED_PARAMETER( param );
Or by removing the name of the parameter from the function:
void doSomething(int /*param*/) { ...
I prefer the latter, because it means that param is definitely not used. I've seen instances of UNREFERENCED_PARAMETER being specified, then later in the code the parameter is actually used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With