TRACE宏(afx.h, AfxTrace)
(TRACE将信息输出到afxDump对象,只在_DEBUG定义时输出,最多输出512个字符,格式化与printf相似)
afxDump对象(afx.h, CDumpContext)
(afxDump调用OutputDebugString把信息输出到Debug窗口,继承CObject的类能够重载Dump方法格式化此类的Dump信息,输出时把afxDump做为Dump方法的参数)
OutputDebugString(windows.h)
(TRACE, afxDump在使用MFC时使用,不使用MFC时能够用OutputDebugString,AfxOutputDebugString和OutputDebugString用法同样)windows
用法示例:code
int nCount = 9;
对象
CString strDesc("total");
继承
TRACE("Count = %d, Description = %s\n", nCount, strDesc);
ip
#ifdef _DEBUG
io
afxDump << "Count = " << nCount
class
<< ", Description = " << strDesc << "\n";
bug
#endif // _DEBUG
方法
#ifdef _DEBUG
di
char strErr[512];
sprintf(strErr, "Count = %d, Description = %s\n", nCount, strDesc);
OutputDebugString()strErr;
#endif // _DEBUG