From 5a07594e424673eddf5a5b39085db55952d7601f Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 15 Oct 2023 17:48:10 -0400 Subject: [PATCH] fix assert --- include/blt/std/assert.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/blt/std/assert.h b/include/blt/std/assert.h index 5962720..ad7028c 100644 --- a/include/blt/std/assert.h +++ b/include/blt/std/assert.h @@ -19,7 +19,12 @@ namespace blt // prints error with stack trace if assertion fails. Does not stop execution. #define blt_assert(expr) do {static_cast(expr) ? void(0) : blt::b_assert_failed(#expr, __FILE__, __LINE__) } while (0) // prints error with stack trace then exits with failure. -#define BLT_ASSERT(expr) do {static_cast(expr) ? void(0) : blt::b_assert_failed(#expr, __FILE__, __LINE__); std::exit(EXIT_FAILURE); } while (0) +#define BLT_ASSERT(expr) do { \ + if (!static_cast(expr)) { \ + blt::b_assert_failed(#expr, __FILE__, __LINE__); \ + std::exit(EXIT_FAILURE); \ + } \ + } while (0) // prints as error but does not throw the exception. #define blt_throw(throwable) do {blt::b_throw(throwable.what(), __FILE__, __LINE__);} while (0) // prints as error with stack trace and throws the exception.