00001 /* 00002 /-------------------------------------------------------------------- 00003 | 00004 | $Id: pldebug_8h-source.html,v 1.1 2004/06/06 12:56:40 uzadow Exp $ 00005 | 00006 | Plattform-independent support for PLASSERT_VALID, PLTRACE and 00007 | PLASSERT. 00008 | 00009 | Copyright (c) 1996-2002 Ulrich von Zadow 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 //------------- PLASSERT_VALID 00023 #ifdef _DEBUG 00024 #define PLASSERT_VALID(pOb) (pOb)->AssertValid() 00025 #else 00026 #define PLASSERT_VALID(pOb) do{} while (0) 00027 #endif 00028 00029 //------------- TRACE 00030 #ifdef _DEBUG 00031 // Inlined to avoid differing linker signatures for debug and release 00032 // versions of paintlib. 00033 void PLTrace(const char * pszFormat, ...); 00034 #define PLTRACE ::PLTrace 00035 #else 00036 // This will be optimized away in release mode and still allow TRACE 00037 // to take a variable amount of arguments :-). 00038 inline void PLTrace (const char *, ...) { } 00039 #define PLTRACE 1 ? (void)0 : ::PLTrace 00040 #endif 00041 00042 //------------- ASSERT 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 //------------- CompilerAssert template for conditional 00087 // compile time error generation. 00088 00089 #define PLCOMPILER_ASSERT(cond) (void)sizeof(int[bool(cond)?1:-1]); 00090 00091 00092 #endif // INCL_PLDEBUG 00093 00094 /* 00095 /-------------------------------------------------------------------- 00096 | 00097 | $Log: pldebug_8h-source.html,v $ 00097 | Revision 1.1 2004/06/06 12:56:40 uzadow 00097 | Doxygenified documentation. 00097 | 00098 | Revision 1.4 2004/03/10 21:36:43 uzadow 00099 | pltester now has sensible output in non-debug mode. 00100 | 00101 | Revision 1.3 2002/03/31 13:36:41 uzadow 00102 | Updated copyright. 00103 | 00104 | Revision 1.2 2001/10/21 17:12:39 uzadow 00105 | Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel. 00106 | 00107 | Revision 1.1 2001/09/16 19:03:22 uzadow 00108 | Added global name prefix PL, changed most filenames. 00109 | 00110 | Revision 1.3 2000/12/04 23:55:40 uzadow 00111 | no message 00112 | 00113 | Revision 1.2 2000/12/04 13:28:17 uzadow 00114 | Changed PLASSERT to use int 3 in windows builds. 00115 | 00116 | Revision 1.1 2000/01/17 23:45:07 Ulrich von Zadow 00117 | MFC-Free version. 00118 | 00119 | 00120 \-------------------------------------------------------------------- 00121 */