Skip to content

Commit 000101d

Browse files
committed
C++: Automatically use RUST_CXX_NO_EXCEPTIONS panic backend if the compiler does not support exceptions.
1 parent 33b5c9e commit 000101d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cxx.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ inline namespace cxxbridge1 {
7575

7676
template <typename Exception>
7777
void panic [[noreturn]] (const char *msg) {
78-
#if defined(RUST_CXX_NO_EXCEPTIONS)
78+
// Do not attempt to throw if the compiler explicitly does not support it.
79+
// If __cpp_attributes is not set, the compiler may not implement feature-test macros.
80+
#if defined(RUST_CXX_NO_EXCEPTIONS) || (defined(__cpp_attributes) && !defined(__cpp_exceptions))
7981
std::cerr << "Error: " << msg << ". Aborting." << std::endl;
8082
std::terminate();
8183
#else

0 commit comments

Comments
 (0)