您的位置:首页 > 其它

非mfc程序下使用TRACE,ASSERT,VERIFY

2010-11-05 15:11 513 查看
#pragma once

//----------------------------------------------------------------

//----------------------------------------------------------------

#ifdef _DEBUG

static void MyDebug_Trace(LPCTSTR szFormat, ...)

{

    va_list args;

    va_start(args, szFormat);

    TCHAR szBuffer[MAX_PATH * 2] = {0};

    int nBuf = _vstprintf(szBuffer, szFormat, args);

    if (nBuf < (sizeof(szBuffer) / sizeof(szBuffer[0]) - 1))

        OutputDebugString(szBuffer);

    else

        OutputDebugString(szFormat);

    va_end(args);

}

#define TRACE                    ::MyDebug_Trace

#define TRACE0(sz)              ::MyDebug_Trace(_T("%s"), _T(sz))

#define TRACE1(sz, p1)          ::MyDebug_Trace(_T(sz), p1)

#define TRACE2(sz, p1, p2)      ::MyDebug_Trace(_T(sz), p1, p2)

#define TRACE3(sz, p1, p2, p3)  ::MyDebug_Trace(_T(sz), p1, p2, p3)

#else

inline static void MyDebug_Trace(LPCTSTR, ...) { }

#define TRACE              1 ? (void)0 : ::MyDebug_Trace

#define TRACE0(sz)

#define TRACE1(sz, p1)

#define TRACE2(sz, p1, p2)

#define TRACE3(sz, p1, p2, p3)

#endif

#ifdef _DEBUG

#define ASSERT(x) {if(!(x)) _asm{int 0x03}}

#define VERIFY(x) {if(!(x)) _asm{int 0x03}} // 译注:为调试版本时产生中断有效

#else

#define ASSERT(x)

#define VERIFY(x) x // 译注:为发行版本时不产生中断

#endif
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mfc path list