So I've seen a number of threads explaining how to avoid unreferenced parameter warnings, for instance:
Avoid warning 'Unreferenced Formal Parameter'
C++ What is the purpose of casting to void?
But what I'm wondering is whether the compiler will do anything different based on which approach is used. For example, will the compiled output for the following three situations be any different?
void Method(int /*x*/)
{
// Parameter is left unnamed
}
void Method(int x)
{
x; // This would be the same as UNREFERENCED_PARAMETER(x);
}
void Method(int x)
{
(void)x; // This would be the same as _CRT_UNUSED(x);
}
I'm most interested in this from the standpoint of what the compiler will do, but if you feel strongly for one approach over the others, I'm happy to hear those arguments as well.
I can see no reason why the compiler would treat any of those different. But the only way to tell for sure for your compiler is for you to look at the output of your compiler.
I would prefer the first option since this situation (unused parameters) is what that language feature was designed for.