VC调试时输出调试信息到Debug窗口
weixin_33909059 于 2018-07-18 18:11:00 发布 163 收藏 文章标签: python 版权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用法一样)
用法示例:
-
int nCount = 9;
-
CString strDesc("total");
-
TRACE("Count = %d, Description = %s\n", nCount, strDesc);
-
#ifdef _DEBUG
-
afxDump << "Count = " << nCount
-
<< ", Description = " << strDesc << "\n";
-
#endif // _DEBUG
-
#ifdef _DEBUG
-
char strErr[512];
-
sprintf(strErr, "Count = %d, Description = %s\n", nCount, strDesc);
-
OutputDebugString()strErr;
-
#endif // _DEBUG
转载于:https://my.oschina.net/u/1777508/blog/1858992
标签:输出,VC,TRACE,DEBUG,OutputDebugString,调试信息,Debug,afxDump From: https://www.cnblogs.com/ioriwellings/p/15825380.html