I am trying to setup a project with conditional debugging. What i want is to have a macro debug
which is #defined to some kind of printf/cout/anything when I'm running in debug mode and #defined to null statement when running in production mode. How can I do this:
I have tried using the macro _DEBUG
but I always see my arguments printing regardless of which mode I am running in:
struct debugger{template<typename T> debugger& operator ,(const T& v){std::cerr<<v<<" ";return *this;}}dbg;
#if _DEBUG
#define debug(...) {dbg,__VA_ARGS__;std::cerr<<std::endl;}
#else
#define debug(...) // Just strip off all debug tokens
#endif
In my main:
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a=1,b=2,c=3;
debug(a,b,c);
cin>>a;
}
If it helps, I am using Visual studio 2012