00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef INCL_PLDEBUG
00014 #define INCL_PLDEBUG
00015
00016 #ifdef _DEBUG
00017 #include <stdarg.h>
00018 #include <stdio.h>
00019 #include <stdlib.h>
00020 #endif
00021
00022
00023 #ifdef _DEBUG
00024 #define PLASSERT_VALID(pOb) (pOb)->AssertValid()
00025 #else
00026 #define PLASSERT_VALID(pOb) do{} while (0)
00027 #endif
00028
00029
00030 #ifdef _DEBUG
00031
00032
00033 void PLTrace(const char * pszFormat, ...);
00034 #define PLTRACE ::PLTrace
00035 #else
00036
00037
00038 inline void PLTrace (const char *, ...) { }
00039 #define PLTRACE 1 ? (void)0 : ::PLTrace
00040 #endif
00041
00042
00043
00044 #ifdef _DEBUG
00045 #ifdef _WINDOWS
00046 #define PLASSERT(f) \
00047 if (!(f)) \
00048 { \
00049 PLTRACE ("Assertion failed at %s, %i\n", __FILE__, __LINE__); \
00050 __asm { int 3 } \
00051 }
00052 #else
00053 #define PLASSERT(f) \
00054 if (!(f)) \
00055 { \
00056 PLTRACE ("Assertion failed at %s, %i\n", __FILE__, __LINE__); \
00057 abort(); \
00058 }
00059 #endif
00060 #else
00061 #define PLASSERT(f) do{}while (0)
00062 #endif
00063
00064 #ifdef _DEBUG
00065 inline void PLTrace(const char * pszFormat, ...)
00066 {
00067 va_list args;
00068 va_start(args, pszFormat);
00069
00070 int nBuf;
00071 char szBuffer[4096];
00072
00073 nBuf = vsprintf(szBuffer, pszFormat, args);
00074 PLASSERT(nBuf < 4096);
00075
00076 #ifndef _WINDOWS
00077 fprintf (stderr, szBuffer);
00078 #else
00079 ::OutputDebugStringA (szBuffer);
00080 #endif //_WINDOWS
00081
00082 va_end(args);
00083 }
00084 #endif
00085
00086
00087
00088
00089 #define PLCOMPILER_ASSERT(cond) (void)sizeof(int[bool(cond)?1:-1]);
00090
00091
00092 #endif // INCL_PLDEBUG
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121