#pragma once #include #include #include #include #include "lib/logging/logging.h" #include "lib/utils/bts_debugger.h" #ifdef _WIN32 #define TERMINATE ::_exit(-1); #else #define TERMINATE abort(); #endif #define bts_assert_msg(EXP, msg) \ do { \ if (!(EXP)) { \ LOG(Assert, bts::Fatal, "Assert failure: {} {}", std::string(#EXP), \ std::string(msg)); \ std::this_thread::sleep_for(std::chrono::seconds(1)); \ if (is_debugger_present()) \ debug_break(); \ TERMINATE; \ } \ } while (0) #define bts_assert(EXP) bts_assert_msg(EXP, "") #define bts_assert_msgf(EXP, msg_template, ...) \ do { \ if (!(EXP)) { \ LOG(Assert, bts::Fatal, "Assert failure: {} {}", std::string(#EXP), \ fmt::format(msg_template, __VA_ARGS__)); \ std::this_thread::sleep_for(std::chrono::seconds(1)); \ if (is_debugger_present()) \ debug_break(); \ TERMINATE; \ } \ } while (0) #ifndef NDEBUG #define bts_assert_d bts_assert #else #define bts_assert_d(EXP) #endif