Make custom assert work in wasm

main
Cameron Murphy Reikes 2 years ago
parent 50a9252df3
commit 51a31cc7ea

@ -1,11 +1,21 @@
#include <stdio.h> #include <stdio.h>
#ifdef WEB
#include <assert.h>
#endif
static inline void assert_impl(bool cond, const char *expression) static inline void assert_impl(bool cond, const char *expression)
{ {
if(!cond) if(!cond)
{ {
fprintf(stderr, "Assertion failed: %s\n", expression); fprintf(stderr, "Assertion failed: %s\n", expression);
#ifdef WEB
assert(false);
#elif defined(DESKTOP)
__debugbreak(); __debugbreak();
#else
#error "Don't know how to assert for current platform configuration"
#endif
} }
} }
#ifdef assert #ifdef assert

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#define DESKTOP
#include "better_assert.h" #include "better_assert.h"
#include "buff.h" #include "buff.h"

@ -2,12 +2,18 @@
// you will die someday // you will die someday
#define SOKOL_IMPL #define SOKOL_IMPL
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32)
#define DESKTOP #define DESKTOP
#define WINDOWS #define WINDOWS
#define SOKOL_D3D11 #define SOKOL_D3D11
#endif #endif
#if defined(__EMSCRIPTEN__)
#define WEB
#define SOKOL_GLES2
#endif
#ifdef WINDOWS #ifdef WINDOWS
#include <Windows.h> #include <Windows.h>
#include <processthreadsapi.h> #include <processthreadsapi.h>
@ -15,6 +21,7 @@
#endif #endif
#include "buff.h" #include "buff.h"
#include "sokol_app.h" #include "sokol_app.h"
#include "sokol_gfx.h" #include "sokol_gfx.h"

Loading…
Cancel
Save