I can do this in Visual C++ 2008 with Release (NDEBUG) setting:
debug.h
#ifdef _DEBUG
void debug_printf(const char* format, ...);
#else
#define debug_printf(format, v) __noop
#endif
debug.cpp
#include "stdafx.h" //#include "debug.h" is inside it
void debug_printf(const char* format, ...) {
//so much work here
}
but not anymore in Visual C++ 2013, I will get compile error in debug.cpp file. It seems I have to change the defining strategy in debug.h. But I wonder is there compiler setting to reenable again the old way?
Use a macro in the first case too, and let it call the actual function (which is named something different from the macro).
And in the second case, just have an empty macro body.
Use variadic macros.
Something like
When
_DEBUG
is not defined, then the macrodebug_printf
is replaced by nothing (or rather, an empty line).