| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- // File: lzham_assert.cpp
- // See Copyright Notice and license at the end of include/lzham.h
- #include "lzham_core.h"
- static bool g_fail_exceptions;
- static bool g_exit_on_failure = true;
- void lzham_enable_fail_exceptions(bool enabled)
- {
- g_fail_exceptions = enabled;
- }
- void lzham_assert(const char* pExp, const char* pFile, unsigned line)
- {
- char buf[512];
- sprintf_s(buf, sizeof(buf), "%s(%u): Assertion failed: \"%s\"\n", pFile, line, pExp);
- lzham_output_debug_string(buf);
- //printf("%s", buf);
- if (lzham_is_debugger_present())
- lzham_debug_break();
- }
- void lzham_fail(const char* pExp, const char* pFile, unsigned line)
- {
- char buf[512];
- sprintf_s(buf, sizeof(buf), "%s(%u): Failure: \"%s\"\n", pFile, line, pExp);
- lzham_output_debug_string(buf);
- //printf("%s", buf);
- if (lzham_is_debugger_present())
- lzham_debug_break();
- #if LZHAM_USE_WIN32_API
- if (g_fail_exceptions)
- RaiseException(LZHAM_FAIL_EXCEPTION_CODE, 0, 0, NULL);
- else
- #endif
- if (g_exit_on_failure)
- exit(EXIT_FAILURE);
- }
- void lzham_trace(const char* pFmt, va_list args)
- {
- /*if (lzham_is_debugger_present()) ESENTHEL CHANGED
- {
- char buf[512];
- vsprintf_s(buf, sizeof(buf), pFmt, args);
- lzham_output_debug_string(buf);
- }*/
- };
- void lzham_trace(const char* pFmt, ...)
- {
- va_list args;
- va_start(args, pFmt);
- lzham_trace(pFmt, args);
- va_end(args);
- };
|