From 465f1a4fc863105ba3074cd2454339729d69c801 Mon Sep 17 00:00:00 2001 From: Brett Date: Thu, 7 Sep 2023 00:21:02 -0400 Subject: [PATCH] fix assert not requiring ; at the end --- include/blt/std/assert.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/blt/std/assert.h b/include/blt/std/assert.h index 49cea36..45934d5 100644 --- a/include/blt/std/assert.h +++ b/include/blt/std/assert.h @@ -35,13 +35,13 @@ namespace blt } // prints error with stack trace if assertion fails. Does not stop execution. -#define blt_assert(expr) static_cast(expr) ? void(0) : blt::b_assert_failed(#expr, __FILE__, __LINE__) +#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) {static_cast(expr) ? void(0) : blt::b_assert_failed(#expr, __FILE__, __LINE__); std::exit(EXIT_FAILURE); } +#define BLT_ASSERT(expr) do {static_cast(expr) ? void(0) : 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) {blt::b_throw(throwable.what(), __FILE__, __LINE__);} +#define blt_throw(throwable) do {blt::b_throw(throwable.what(), __FILE__, __LINE__);} while (0) // prints as error with stack trace and throws the exception. -#define BLT_THROW(throwable) {blt::b_throw(throwable.what(), __FILE__, __LINE__); throw throwable;} +#define BLT_THROW(throwable) do {blt::b_throw(throwable.what(), __FILE__, __LINE__); throw throwable;} while(0) #endif //BLT_ASSERT_H