From c9fef8d83fe48f233372b890fcfd184ef68a9b69 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Thu, 2 Jan 2025 18:19:38 +0100 Subject: Add assertion failure handler --- asl/assert.hpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'asl/assert.hpp') diff --git a/asl/assert.hpp b/asl/assert.hpp index d95159a..bf6a795 100644 --- a/asl/assert.hpp +++ b/asl/assert.hpp @@ -1,6 +1,14 @@ #pragma once #include "asl/config.hpp" +#include "asl/meta.hpp" + +namespace asl +{ + +void report_assert_failure( const char* msg, const source_location& sl = source_location{}); + +} // namespace asl #if ASL_COMPILER_CLANG_CL #define ASL_DEBUG_BREAK() __debugbreak() @@ -10,8 +18,16 @@ #define ASL_ASSERT(...) \ if (__VA_ARGS__) {} \ - else { ASL_DEBUG_BREAK(); } + else \ + { \ + ::asl::report_assert_failure(#__VA_ARGS__); \ + ASL_DEBUG_BREAK(); \ + } #define ASL_ASSERT_RELEASE(...) \ if (__VA_ARGS__) {} \ - else { ASL_DEBUG_BREAK(); } + else \ + { \ + ::asl::report_assert_failure(#__VA_ARGS__); \ + ASL_DEBUG_BREAK(); \ + } -- cgit