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