Browse Source

Make hsAssert useful on Linux

Michael Hansen 10 years ago
parent
commit
46761ee07d
  1. 16
      Sources/Plasma/CoreLib/HeadSpin.cpp

16
Sources/Plasma/CoreLib/HeadSpin.cpp

@ -118,17 +118,20 @@ void ErrorAssert(int line, const char* file, const char* fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vsnprintf(msg, arrsize(msg), fmt, args); vsnprintf(msg, arrsize(msg), fmt, args);
#if defined(HS_DEBUGGING) && defined(_MSC_VER) #if defined(HS_DEBUGGING)
#if defined(_MSC_VER)
if (s_GuiAsserts) if (s_GuiAsserts)
{ {
if(_CrtDbgReport(_CRT_ASSERT, file, line, NULL, msg)) if (_CrtDbgReport(_CRT_ASSERT, file, line, NULL, msg))
DebugBreak(); DebugBreak();
} else } else
#endif // HS_DEBUGGING #endif // _MSC_VER
if (DebugIsDebuggerPresent()) { {
char str[] = "-------\nASSERTION FAILED:\nFile: %s Line: %i\nMessage: %s\n-------"; char str[] = "-------\nASSERTION FAILED:\nFile: %s Line: %i\nMessage: %s\n-------";
DebugMsg(str, file, line, msg); DebugMsg(str, file, line, msg);
abort();
} }
#endif // HS_DEBUGGING
#else #else
DebugBreakIfDebuggerPresent(); DebugBreakIfDebuggerPresent();
#endif // defined(HS_DEBUGGING) || !defined(PLASMA_EXTERNAL_RELEASE) #endif // defined(HS_DEBUGGING) || !defined(PLASMA_EXTERNAL_RELEASE)
@ -164,13 +167,14 @@ void DebugMsg(const char* fmt, ...)
va_start(args, fmt); va_start(args, fmt);
vsnprintf(msg, arrsize(msg), fmt, args); vsnprintf(msg, arrsize(msg), fmt, args);
#ifdef _MSC_VER
if (DebugIsDebuggerPresent()) if (DebugIsDebuggerPresent())
{ {
#ifdef _MSC_VER
OutputDebugStringA(msg); OutputDebugStringA(msg);
OutputDebugStringA("\n"); OutputDebugStringA("\n");
} else
#endif #endif
} else { {
fprintf(stderr, "%s\n", msg); fprintf(stderr, "%s\n", msg);
} }
} }

Loading…
Cancel
Save