Given the following piece of code:
void test(int var)
{
Q_UNUSED(var);
#ifdef SOMETHING
printf("%d",var);
//do something else with var...
#endif
}
Would the Q_UNUSED
macro have any effect if I actually use the 'var' variable in some scenario (like in the example above), or it has no effect at all when I suppress compiler warnings for unused variables?
So far I observe it has no effect, but I would like to make sure.
((void)(expression));
– Plutoniumvar
to make any subsequent use ambiguous?extern qUnusedType var;
– Aciculate[[maybe_unused]]
on the parameter definition, instead of letting you mark points in the control flow after which you don't want a variable used and have the compiler catch it.) – Candor