]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/debugging/debugging.h
[q3map2] Unwind script stack in case of script loading error.
[xonotic/netradiant.git] / libs / debugging / debugging.h
index e05ff31b41ecd10b0a013652979e0ab000be1f52..405131d24433703cffaf095d5ee5fde618c888bc 100644 (file)
 /// \file
 /// \brief Debugging macros for fatal error/assert messages.
 
+#include "globaldefs.h"
 #include "stream/textstream.h"
 #include "warnings.h"
 #include "generic/static.h"
 
-#if defined( _MSC_VER ) && ( defined( _M_IX86 ) || defined( _M_AMD64 ) )
+#if GDEF_COMPILER_MSVC && ( defined( _M_IX86 ) || defined( _M_AMD64 ) )
 #define DEBUGGER_BREAKPOINT() __asm { int 3 }
-#elif ( defined ( __i386__ ) || defined ( __x86_64__ ) ) && defined ( __GNUC__ ) && __GNUC__ >= 2
+#elif GDEF_COMPILER_GNU && __GNUC__ >= 2 && ( defined ( __i386__ ) || defined ( __x86_64__ ) )
 #define DEBUGGER_BREAKPOINT() __asm__ __volatile__ ( "int $03" )
 #else
 #include <signal.h>
 #define DEBUGGER_BREAKPOINT() raise( SIGTRAP );
 #endif
 
-#define STR( x )  # x
+#define STR( x )  #x
 #define STR2( x ) STR( x )
 #define FILE_LINE __FILE__ ":" STR2( __LINE__ )
 
-#if defined( _DEBUG ) || 1
 #define DEBUG_ASSERTS
-#endif
 
 class DebugMessageHandler
 {
@@ -72,7 +71,7 @@ virtual TextOutputStream& getOutputStream(){
        return globalErrorStream();
 }
 virtual bool handleMessage(){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
        return false; // send debug-break
 #else
        return true;
@@ -116,8 +115,8 @@ inline DebugMessageHandler& globalDebugMessageHandler(){
                globalDebugMessageHandler().getOutputStream() << FILE_LINE "\nruntime error: " << message << "\n"; \
                if ( !globalDebugMessageHandler().handleMessage() ) { DEBUGGER_BREAKPOINT(); }} while ( 0 )
 
-#define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != 0, "pointer \"" # ptr "\" is null" )
-#define ASSERT_TRUE( flag ) ASSERT_MESSAGE( !!(flag) == true, "condition \"" # flag "\" is false" )
+#define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != 0, "pointer \"" #ptr "\" is null" )
+#define ASSERT_TRUE( flag ) ASSERT_MESSAGE( !!(flag) == true, "condition \"" #flag "\" is false" )
 
 #else