diff --git a/luna/include/luna/Check.h b/luna/include/luna/Check.h index fce54b96..fe1c7f50 100644 --- a/luna/include/luna/Check.h +++ b/luna/include/luna/Check.h @@ -8,6 +8,18 @@ extern _noreturn bool __check_failed(const char* file, const char* line, const c #define STRINGIZE_VALUE_OF(x) STRINGIZE(x) #endif -#define check(expr) (expr) || __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr) #define expect(expr, message) \ - (expr) || __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, message) + do { \ + if (!(expr)) [[unlikely]] \ + { \ + __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, message); \ + } \ + } while (0) + +#define check(expr) \ + do { \ + if (!(expr)) [[unlikely]] \ + { \ + __check_failed(__FILE__, STRINGIZE_VALUE_OF(__LINE__), __PRETTY_FUNCTION__, #expr); \ + } \ + } while (0)