00001
00002
00003
00004
00005
00006
00007 #ifndef DEBUG_H
00008 #define DEBUG_H
00009
00010
00011 #if !(defined(DEBUG) ^ defined(NDEBUG))
00012 #error DEBUG and NDEBUG are out of sync!
00013 #endif
00014
00015
00016 #ifdef __MSL__
00017 #if __MSL__ && DEBUG != defined(MSIPL_DEBUG_MODE)
00018 #error DEBUG and MSIPL_DEBUG_MODE are out of sync!
00019 #endif
00020 #endif
00021
00022
00023 #ifdef TARGET_COMPILER_VC
00024 #if _MSC_VER >= 1100 && DEBUG != defined(_DEBUG)
00025 #error DEBUG and _DEBUG are out of sync!
00026 #endif
00027 #endif
00028
00029
00030 #ifndef _lint
00031 #define COMPILE_CHECK(expr, tag) typedef char compile_check_ ## tag[(expr) ? 1 : -1]
00032 #else
00033 #define COMPILE_CHECK(expr, tag)
00034 #endif
00035
00036 #if defined(DEBUG) && !defined(ASSERTS)
00037 #define ASSERTS
00038 #endif
00039
00040 #ifdef ASSERTS
00041
00042 NORETURN void AssertFailed(const char *expr, const char *file, int line, bool save_game);
00043
00044 #define ASSERT_SAVE(p) \
00045 do { \
00046 if (!(p)) AssertFailed(#p, __FILE__, __LINE__, true); \
00047 } while (false)
00048
00049 #define ASSERT(p) \
00050 do { \
00051 if (!(p)) AssertFailed(#p, __FILE__, __LINE__, false); \
00052 } while (false)
00053
00054 #define VERIFY(p) ASSERT(p)
00055
00056 #else
00057
00058 #define ASSERT_SAVE(p) ((void) 0)
00059 #define ASSERT(p) ((void) 0)
00060 #define VERIFY(p) do {if (p) ;} while (false)
00061
00062 inline void __DUMMY_TRACE__(...)
00063 {
00064 }
00065
00066 #endif
00067
00068 NORETURN void die(const char *file, int line, const char *format, ...);
00069 #define die(...) die(__FILE__, __LINE__, __VA_ARGS__)
00070
00071 #ifdef DEBUG
00072 void debuglog(const char *format, ...);
00073 #endif
00074 #endif