|
|
@ -4,29 +4,43 @@
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WEB
|
|
|
|
#ifdef WEB
|
|
|
|
//#include <assert.h>
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
|
|
|
#define game_debugbreak() raise(SIGTRAP)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define game_assert_4127_push
|
|
|
|
|
|
|
|
#define game_assert_4127_pop
|
|
|
|
|
|
|
|
|
|
|
|
static void assert_impl(bool cond, const char *expression)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!cond)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(stderr, "Assertion failed: %s\n", expression);
|
|
|
|
|
|
|
|
#ifdef WEB
|
|
|
|
|
|
|
|
raise(SIGTRAP);
|
|
|
|
|
|
|
|
//assert(false);
|
|
|
|
|
|
|
|
#elif defined(DESKTOP)
|
|
|
|
#elif defined(DESKTOP)
|
|
|
|
__debugbreak();
|
|
|
|
#define game_debugbreak() __debugbreak()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define game_assert_4127_push __pragma(warning(push)) __pragma(warning(disable:4127))
|
|
|
|
|
|
|
|
#define game_assert_4127_pop __pragma(warning(pop))
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#error "Don't know how to assert for current platform configuration"
|
|
|
|
#error "Don't know how to assert for current platform configuration"
|
|
|
|
|
|
|
|
#define game_debugbreak() (void)(0)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void assert_impl(const char *func, const char *file, long line, const char *expression)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(stderr, "Assert fail in %s(%s:%ld):\n \"%s\"\n", func, file, line, expression);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
|
|
|
#define game_assert(cond) game_assert_4127_push do { (void)0; } while (0) game_assert_4127_pop
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define game_assert(cond) game_assert_4127_push do { \
|
|
|
|
|
|
|
|
if (!(cond)) { \
|
|
|
|
|
|
|
|
assert_impl(__func__, __FILE__, __LINE__, #cond); \
|
|
|
|
|
|
|
|
game_debugbreak(); \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
} while (0) game_assert_4127_pop
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef assert
|
|
|
|
#ifdef assert
|
|
|
|
#undef assert
|
|
|
|
#undef assert
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define assert game_assert
|
|
|
|
#define assert(cond) assert_impl(cond, #cond)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define Log(...) { printf("%s Log %d | ", __FILE__, __LINE__); printf(__VA_ARGS__); }
|
|
|
|
#define Log(...) { printf("%s Log %d | ", __FILE__, __LINE__); printf(__VA_ARGS__); }
|