Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
CDebug.h
00001 #ifndef __cDEBUG_h__ 00002 #define __cDEBUG_h__ 00003 00005 // MarSTD version 2004 - (c)2004 - Marcel Smit // 00006 // // 00007 // [email protected] // 00008 // [email protected] // 00009 // // 00010 // This code may not be used in a commercial product without my // 00011 // permission. If you redistribute it, this message must remain // 00012 // intact. If you use this code, some acknowledgement would be // 00013 // appreciated. ;-) // 00015 00016 #if defined(MARSTD_DEBUG) 00017 00018 //#define USE_ALLEGRO ///< Uncomment to use Allegro's output functions to display error information. 00019 00020 #if defined(USE_ALLEGRO) 00021 #include <allegro.h> 00022 #endif 00023 00024 #include <signal.h> 00025 #include <stdarg.h> 00026 00027 #if defined(USE_ALLEGRO) 00028 static bool marstd_exceptionbox(char* text, bool autoabort) 00029 { 00030 00031 allegro_message(text); 00032 00033 return autoabort; 00034 00035 } 00036 #else 00037 #include <stdio.h> 00038 static bool marstd_exceptionbox(char* text, bool autoabort) 00039 { 00040 00041 printf(text); 00042 00043 return autoabort; 00044 00045 } 00046 #endif 00047 00055 static void marstd_exception(bool autoabort, int code, char* format, ...) 00056 { 00057 00058 char text[1024]; 00059 00060 va_list ap; 00061 va_start(ap, format); 00062 vsprintf(text, format, ap); 00063 va_end(ap); 00064 00065 if (marstd_exceptionbox(text, autoabort)) 00066 raise(SIGABRT); 00067 00068 } 00069 00070 #endif 00071 00072 #if defined(MARSTD_DEBUG) 00073 #if 1 00074 #define MASSERT(value) \ 00075 if (!(value)) \ 00076 { \ 00077 marstd_exception(true, -1, "%s: %s: %d: %s", __FILE__, __FUNCTION__, __LINE__, ":-("); \ 00078 } 00079 #else 00080 static inline void MASSERT(bool value) 00081 { 00082 if (!value) 00083 { 00084 marstd_exception(true, -1, "%s: %s: %d: %s", __FILE__, __FUNCTION__, __LINE__, ":-("); 00085 } 00086 } 00087 #endif 00088 #else 00089 #define MASSERT(value) 00090 #endif 00091 00092 #endif
Generated on Tue Feb 8 21:59:02 2005 for MarSTDv2004 by
