我的调试输出_TRACE 第二版

#ifdef _DEBUG class __CTrace { CString szFileAndLine; public: __CTrace(LPCTSTR szFile, int nLien) { szFileAndLine.Format(_T("%s(%d): "), szFile, nLien); } void __cdecl operator()(LPCTSTR format, ...) const { TCHAR szInfo[1024] ={0}; va_list arg; va_start(arg, format); _vstprintf_s(szInfo, 1024, format, arg); va_end(arg); OutputDebugString(szFileAndLine); OutputDebugString(szInfo); } }; #define _TRACE __CTrace(_T(__FILE__), __LINE__) #else #define _TRACE(...) __noop #endif

 

//应用举例

//类似TRACE宏一样使用  只需要前面加一下划线

//但是比TRACE的优势就是双击调试框中的输出行 可以定位到源代码出

_TRACE(_T("Value = %d\r\n"), Val);

 

你可能感兴趣的:(list,File,Class)