我想用條件調試來設置一個項目。我想要的是有一個宏debug
這是#defined某種printf/cout /任何東西,當我在調試模式下運行和#defined爲生產模式下運行時爲空語句。我怎樣才能做到這一點:Visual C++有條件的調試
我已經使用宏_DEBUG
嘗試,但我總能看到我的論點打印無論哪種模式,我在運行:
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
在我的主:
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a=1,b=2,c=3;
debug(a,b,c);
cin>>a;
}
如果有幫助,我正在使用Visual Studio 2012
你是怎樣嘗試'_DEBUG'?你也可以嘗試'OutputDebugString'。 – chris
@chris:已更新 – prongs
'#if defined _DEBUG'?或標準的'#ifndef NDEBUG' –