From 000101de4219cf1c8702b681e4a86f09941cfb38 Mon Sep 17 00:00:00 2001 From: riidefi <34194588+riidefi@users.noreply.github.com> Date: Sat, 11 Feb 2023 16:10:28 -0700 Subject: [PATCH] C++: Automatically use `RUST_CXX_NO_EXCEPTIONS` panic backend if the compiler does not support exceptions. --- src/cxx.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cxx.cc b/src/cxx.cc index 4958eb08b..b15c80ea6 100644 --- a/src/cxx.cc +++ b/src/cxx.cc @@ -75,7 +75,9 @@ inline namespace cxxbridge1 { template void panic [[noreturn]] (const char *msg) { -#if defined(RUST_CXX_NO_EXCEPTIONS) +// Do not attempt to throw if the compiler explicitly does not support it. +// If __cpp_attributes is not set, the compiler may not implement feature-test macros. +#if defined(RUST_CXX_NO_EXCEPTIONS) || (defined(__cpp_attributes) && !defined(__cpp_exceptions)) std::cerr << "Error: " << msg << ". Aborting." << std::endl; std::terminate(); #else