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
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有