81 lines
1.6 KiB
C
81 lines
1.6 KiB
C
|
|
#ifndef _MDBG_H_
|
|||
|
|
#define _MDBG_H_
|
|||
|
|
|
|||
|
|
/* <09><><EFBFBD><EFBFBD>Win32Ӧ<32>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>Assert<72><74> */
|
|||
|
|
#ifndef Assert
|
|||
|
|
|
|||
|
|
#ifdef _DEBUG
|
|||
|
|
#include <assert.h>
|
|||
|
|
#define Assert assert
|
|||
|
|
#define DbgAssert assert
|
|||
|
|
#else
|
|||
|
|
#define Assert(exp) (exp)
|
|||
|
|
#define DbgAssert(exp) //ʲô<CAB2><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif // --> #ifndef Assert
|
|||
|
|
|
|||
|
|
#ifndef TRACE
|
|||
|
|
|
|||
|
|
#ifdef _DEBUG
|
|||
|
|
#define TRACE _mdbgOutputDbgStr
|
|||
|
|
|
|||
|
|
static void _mdbgOutputDbgStr(const char* szFormat, ...)
|
|||
|
|
{
|
|||
|
|
static char szStaticBuf[4096];
|
|||
|
|
|
|||
|
|
va_list args;
|
|||
|
|
va_start(args, szFormat);
|
|||
|
|
vsprintf(szStaticBuf, szFormat, args);
|
|||
|
|
va_end(args);
|
|||
|
|
#ifdef _MSC_VER
|
|||
|
|
OutputDebugString(szStaticBuf);
|
|||
|
|
#else
|
|||
|
|
perror(szStaticBuf);
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
#else
|
|||
|
|
#define TRACE
|
|||
|
|
#endif
|
|||
|
|
#endif // --> #ifndef TRACE
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* <09><><EFBFBD>嵱ǰ<E5B5B1>ļ<EFBFBD><C4BC>Լ<EFBFBD><D4BC>е<EFBFBD><D0B5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ĺ<EFBFBD>(<28><>ȡ<EFBFBD><C8A1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>磺abc.cpp(2000)) */
|
|||
|
|
#ifndef __FILE_LINE__
|
|||
|
|
|
|||
|
|
|
|||
|
|
#define _TLN(LN) #LN
|
|||
|
|
#define __TLINE__(LN) _TLN(LN)
|
|||
|
|
#define __FILE_LINE__ __FILE__"("__TLINE__(__LINE__)")"
|
|||
|
|
|
|||
|
|
#endif // --> #ifndef __FILE_LINE__
|
|||
|
|
|
|||
|
|
/* <09><><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĺ꣬<C4BA><EAA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Լ<EFBFBD><D4BC>кŲ<D0BA><C5B2><EFBFBD>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӷ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
|
#ifndef __CPMSG__
|
|||
|
|
|
|||
|
|
#define __CPMSG__(MSG) message( __FILE_LINE__ " : " #MSG )
|
|||
|
|
|
|||
|
|
#endif // --> ifndef __CPMSG__
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>SafeDelete<74><65>SafeDeleteArray<61><79>SafeFree<65>Լ<EFBFBD>SafeRelease<73><65> */
|
|||
|
|
#ifndef SafeDelete
|
|||
|
|
#define SafeDelete(p) if (p) { delete p; p = NULL; }
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef SafeDeleteArray
|
|||
|
|
#define SafeDeleteArray(p) if (p) { delete [] p; p = NULL; }
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef SafeFree
|
|||
|
|
#define SafeFree(p) if (p) { free(p); p = NULL; }
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef SafeRelease
|
|||
|
|
#define SafeRelease(p) if (p){ p->Release(); p = NULL; }
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#define ArrayCount(a) (sizeof(a) / sizeof((a)[0]))
|
|||
|
|
|
|||
|
|
#endif
|