From 0c408390096c6593285594ffe10c404946d8db73 Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:07:15 -0600 Subject: [PATCH] Specify __cdecl for the terminate handler on MSVC, fixes #197 --- src/utils.cpp | 2 +- src/utils/common.hpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils.cpp b/src/utils.cpp index ce2917f..0841841 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -40,7 +40,7 @@ namespace cpptrace { } } - [[noreturn]] void terminate_handler() { + [[noreturn]] void MSVC_CDECL terminate_handler() { // TODO: Support std::nested_exception? try { auto ptr = std::current_exception(); diff --git a/src/utils/common.hpp b/src/utils/common.hpp index faf6779..c15d87f 100644 --- a/src/utils/common.hpp +++ b/src/utils/common.hpp @@ -25,6 +25,12 @@ #define NODISCARD #endif +#if IS_MSVC + #define MSVC_CDECL __cdecl +#else + #define MSVC_CDECL +#endif + namespace cpptrace { namespace detail { static const stacktrace_frame null_frame {