D
Dombo
Op 02-Apr-12 13:16, Qi schreef:
I have seen it before, but not frequently and usually wrapped in macro.
I agree that code readability (easy to understand) is very important.
Personally I prefer to just comment out the parameter name. It is less
typing and is pretty clear even to less experienced coders. The purpose
of (void)param; will not be obvious to everyone,unless wrapped in a
macro with an obvious name.
Hi all,
Let me show some code first,
void someFunction(int param)
{
(void)param; // param is not used in this function. This line is
// just to silence the compiler warning about unused param.
}
Please note the "(void)param".
Is that usage common or well known for you?
Or you rarely saw it? Or even it's weird to you?
I have seen it before, but not frequently and usually wrapped in macro.
Just your experience is enough, no need to debate for it's good
or bad.
The reason I ask this is, in my another thread, some very veteran
C++ developers said they rarely saw that kind of usage.
That makes me a little nervous because I used it a lot in my
code to *improve* the code readability.
If it's not well known trick then it reduces code readability
and then I'm going to change my code about that.
That's not only about coding style but also about code readability.
I agree that code readability (easy to understand) is very important.
Personally I prefer to just comment out the parameter name. It is less
typing and is pretty clear even to less experienced coders. The purpose
of (void)param; will not be obvious to everyone,unless wrapped in a
macro with an obvious name.