Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

pldebug.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: pldebug_8h-source.html,v 1.4 2004/09/15 15:26:29 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 #ifdef _WINDOWS
00021 #define WIN32_LEAN_AND_MEAN  /* Prevent including <winsock*.h> in <windows.h> */
00022 #define VC_EXTRALEAN  // Exclude rarely-used stuff from Windows headers
00023 #include <windows.h>  // For OutputDebugString
00024 #endif
00025 #endif
00026 
00027 //------------- PLASSERT_VALID
00028 #ifdef _DEBUG
00029   #define PLASSERT_VALID(pOb) (pOb)->AssertValid()
00030 #else
00031   #define PLASSERT_VALID(pOb) do{} while (0)
00032 #endif
00033 
00034 //------------- TRACE
00035 #ifdef _DEBUG
00036   // Inlined to avoid differing linker signatures for debug and release
00037   // versions of paintlib.
00038   void PLTrace(const char * pszFormat, ...); 
00039   #define PLTRACE ::PLTrace
00040 #else
00041   // This will be optimized away in release mode and still allow TRACE
00042   // to take a variable amount of arguments :-).
00043   inline void PLTrace (const char *, ...) { }
00044   #define PLTRACE  1 ? (void)0 : ::PLTrace
00045 #endif
00046 
00047 //------------- ASSERT
00048 
00049 #ifdef _DEBUG
00050   #ifdef _WINDOWS
00051     #define PLASSERT(f)            \
00052       if (!(f))                    \
00053         {                          \
00054           PLTRACE ("Assertion failed at %s, %i\n", __FILE__, __LINE__); \
00055           __asm { int 3 }          \
00056         }
00057   #else
00058     #define PLASSERT(f)            \
00059       if (!(f))                    \
00060         {                          \
00061           PLTRACE ("Assertion failed at %s, %i\n", __FILE__, __LINE__); \
00062           abort();                 \
00063         }
00064   #endif
00065 #else
00066   #define PLASSERT(f) do{}while (0)
00067 #endif
00068 
00069 #ifdef _DEBUG
00070   inline void PLTrace(const char * pszFormat, ...)
00071   {
00072     va_list args;
00073     va_start(args, pszFormat);
00074 
00075     int nBuf;
00076     char szBuffer[4096];
00077 
00078     nBuf = vsprintf(szBuffer, pszFormat, args);
00079     PLASSERT(nBuf < 4096);
00080 
00081 #ifndef _WINDOWS
00082     fprintf (stderr, szBuffer);
00083 #else
00084     ::OutputDebugString (szBuffer);
00085 #endif //_WINDOWS
00086 
00087     va_end(args);
00088   }
00089 #endif
00090 
00091 //------------- CompilerAssert template for conditional
00092 //              compile time error generation.
00093 
00094 #define PLCOMPILER_ASSERT(cond) (void)sizeof(int[bool(cond)?1:-1]);
00095 
00096 
00097 #endif // INCL_PLDEBUG
00098 
00099 /*
00100 /--------------------------------------------------------------------
00101 |
00102 |      $Log: pldebug_8h-source.html,v $
00102 |      Revision 1.4  2004/09/15 15:26:29  uzadow
00102 |      Linux compatibility changes, doc update.
00102 |
00103 |      Revision 1.7  2004/09/11 12:41:35  uzadow
00104 |      removed plstdpch.h
00105 |
00106 |      Revision 1.6  2004/06/13 20:19:27  uzadow
00107 |      no message
00108 |
00109 |      Revision 1.5  2004/06/06 12:56:38  uzadow
00110 |      Doxygenified documentation.
00111 |
00112 |      Revision 1.4  2004/03/10 21:36:43  uzadow
00113 |      pltester now has sensible output in non-debug mode.
00114 |
00115 |      Revision 1.3  2002/03/31 13:36:41  uzadow
00116 |      Updated copyright.
00117 |
00118 |      Revision 1.2  2001/10/21 17:12:39  uzadow
00119 |      Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.
00120 |
00121 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00122 |      Added global name prefix PL, changed most filenames.
00123 |
00124 |      Revision 1.3  2000/12/04 23:55:40  uzadow
00125 |      no message
00126 |
00127 |      Revision 1.2  2000/12/04 13:28:17  uzadow
00128 |      Changed PLASSERT to use int 3 in windows builds.
00129 |
00130 |      Revision 1.1  2000/01/17 23:45:07  Ulrich von Zadow
00131 |      MFC-Free version.
00132 |
00133 |
00134 \--------------------------------------------------------------------
00135 */

Generated on Mon Sep 13 16:16:40 2004 for paintlib by doxygen 1.3.2