Skip to content

Commit b8c6c85

Browse files
Add weak std::terminate() implementation
This allows calling it from other places later. The default implementation calls `abort()`, but making it weak allows user code to override this function (either directly, or by including a library like uclibc++ that implements `std::set_terminate()`). Note that this does not add a declaration for this function, since the standard dictates this to be in `<exception>`, but we cannot meaningfully or completely implement that header, so better leave it to be overridden by e.g. libraries like uclibc++.
1 parent 4e469e0 commit b8c6c85

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cores/arduino/abi.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
2222
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
2323

24+
namespace std {
25+
[[gnu::weak, noreturn]] void terminate() {
26+
abort();
27+
}
28+
}
29+
2430
void __cxa_pure_virtual(void) {
2531
// We might want to write some diagnostics to uart in this case
2632
//std::terminate();

0 commit comments

Comments
 (0)