Hi,
An old trick was to use sizeof against cast-to-void for unused variable for assert to not have evaluation of the parameter.
Is it still valid nowadays or cast-to-void works on all case nowadays ?
Thanks
Hi,
An old trick was to use sizeof against cast-to-void for unused variable for assert to not have evaluation of the parameter.
Is it still valid nowadays or cast-to-void works on all case nowadays ?
Thanks
I've always just relied on C4100 to tell me when I have unused variables (which won't even let me compile with /Wall and /WX set).
(void)foo;
sizeof(some_expensive_call())
void DoSomething(int foo, char const* debug_name) {
DEBUG_MESSAGE(debug_name);
stuff(foo);
}
void DoSomething(Object* obj) {
DEBUG_MESSAGE(obj->GetDebugName());
stuff(obj);
}
#ifdef DEBUG
# define DEBUG_MESSAGE(msg) puts((msg))
#else
# define DEBUG_MESSAGE(msg) (void)sizeof((msg), 1)
#endif
I use slightly different technique,
void Foo(int /*SomeParameter*/)
This way, I get also quick documentation and shut up compiler warning.