summary refs log tree commit diff
path: root/src/Common/Assert.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/Assert.hpp')
-rw-r--r--src/Common/Assert.hpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Common/Assert.hpp b/src/Common/Assert.hpp
index d30e724..bbafcd6 100644
--- a/src/Common/Assert.hpp
+++ b/src/Common/Assert.hpp
@@ -4,6 +4,17 @@
 #include <cstdio>
 #include <cstring>
 
+namespace Assert::Detail {
+#ifdef _WIN32
+    // MinGW has weird behavior with SIGTRAP,
+    // and debugging won't be done on Windows anyway,
+    // so SIGABRT is used instead.
+    constexpr int DebugSignal = SIGABRT;
+#else
+    constexpr int DebugSignal = SIGTRAP;
+#endif
+}
+
 // https://stackoverflow.com/a/26100478/11342122
 // Two levels are needed to make sure that the argument is expanded before stringification
 #define _ASSERT_IS_DEFINED(x) _ASSERT_IS_DEFINED2(x)
@@ -11,7 +22,7 @@
 #define _ASSERT_IS_DEFINED2(x) (#x[0] == 0 || (#x[0] >= '1' && #x[0] <= '9'))
 
 // Stopping macro, non-fatal in debug mode
-#define _ASSERT_STOP (_ASSERT_IS_DEFINED(NDEBUG) ? std::abort() : (void)raise(SIGTRAP))
+#define _ASSERT_STOP (_ASSERT_IS_DEFINED(NDEBUG) ? std::abort() : (void)raise(Assert::Detail::DebugSignal))
 
 // Assertion message macros, with optional message
 #define _ASSERT_NOTIFY_NO_MESSAGE(start) fprintf(stderr, start ".\n", __FILE__, __LINE__)
@@ -30,4 +41,4 @@
 #define UNREACHABLE(...) do { \
     _ASSERT_NOTIFY("UNREACHABLE() reached at %s:%d", __VA_ARGS__); \
     _ASSERT_STOP; \
-} while (0)
\ No newline at end of file
+} while (0)