fix assert not requiring ; at the end

v1
Brett 2023-09-07 00:21:02 -04:00
parent 650af9877f
commit 465f1a4fc8
1 changed files with 4 additions and 4 deletions

View File

@ -35,13 +35,13 @@ namespace blt
} }
// prints error with stack trace if assertion fails. Does not stop execution. // prints error with stack trace if assertion fails. Does not stop execution.
#define blt_assert(expr) static_cast<bool>(expr) ? void(0) : blt::b_assert_failed(#expr, __FILE__, __LINE__) #define blt_assert(expr) do {static_cast<bool>(expr) ? void(0) : blt::b_assert_failed(#expr, __FILE__, __LINE__) } while (0)
// prints error with stack trace then exits with failure. // prints error with stack trace then exits with failure.
#define BLT_ASSERT(expr) {static_cast<bool>(expr) ? void(0) : blt::b_assert_failed(#expr, __FILE__, __LINE__); std::exit(EXIT_FAILURE); } #define BLT_ASSERT(expr) do {static_cast<bool>(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. // 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. // 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 #endif //BLT_ASSERT_H