diff --git a/include/blah/common.h b/include/blah/common.h index 8b1f661..d24a9fe 100644 --- a/include/blah/common.h +++ b/include/blah/common.h @@ -3,22 +3,42 @@ #include // for in-place constructors, for Vector/StackVector #include // for std::move -// Asserts -#if defined(DEBUG) || defined(_DEBUG) -# include // for abort -# define BLAH_ASSERT(condition, msg) do { if (!(condition)) { Blah::Log::error("%s\n\tin %s:%d", (msg), __FILE__, __LINE__); abort(); } } while(0) -# define BLAH_ASSERT_FMT(condition, msg, ...) do { if (!(condition)) { Blah::Log::error(msg "\n\tin %s:%d", __VA_ARGS__, __FILE__, __LINE__); abort(); } } while(0) +// Aborts +#include // for abort +#ifdef _WIN32 +#define BLAH_ABORT() do { __debugbreak(); ::exit(1); } while(0) #else -# define BLAH_ASSERT(condition, msg) do { if (!(condition)) { Blah::Log::error("%s\n\tin %s:%d", (msg), __FILE__, __LINE__); } } while(0) -# define BLAH_ASSERT_FMT(condition, msg, ...) do { if (!(condition)) { Blah::Log::error(msg "\n\tin %s:%d", __VA_ARGS__, __FILE__, __LINE__); } } while(0) +#define BLAH_ABORT() ::abort() #endif +// Assert Behavior (abort in debug) +#if defined(DEBUG) || defined(_DEBUG) +#define BLAH_ASSERT_BEHAVIOR() BLAH_ABORT() +#else +#define BLAH_ASSERT_BEHAVIOR() +#endif + +// Asserts +#define BLAH_ASSERT(condition, msg) \ + do { \ + if (!(condition)) { \ + Blah::Log::error("%s\n\tin %s:%d", (msg), __FILE__, __LINE__); \ + BLAH_ASSERT_BEHAVIOR(); \ + } \ + } while(0) +#define BLAH_ASSERT_FMT(condition, msg, ...) \ + do { \ + if (!(condition)) { \ + Blah::Log::error(msg "\n\tin %s:%d", __VA_ARGS__, __FILE__, __LINE__); \ + BLAH_ASSERT_BEHAVIOR(); \ + } \ + } while(0) + // Numeric Types #include // for integer types #include // for size_t type namespace Blah { - // Numeric Types using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; @@ -125,4 +145,4 @@ namespace Blah template operator Ref() { increment(); return Ref(static_cast(m_obj), m_num, m_del); } }; } -#endif \ No newline at end of file +#endif