Repository: dtolnay/cxx (language: rust)

Issue:
Avoid using c++'s `stream`?
As in here:

https://github.com/dtolnay/cxx/blob/8308e991189ce6d8c2eb535a5369772d97ff8fb5/src/cxx.cc#L79

we use `std::cerr` which is known to escalate the binary size and is unsuitable for embedded environments. Many people disable exceptions for smaller binary sizes, so I think this request is valid. Can we use `fprintf` instead?

I can submit a PR if accepted.


Discussion / hints:
I would accept a PR to use `fprintf` instead.

Fix patch:
diff --git a/src/cxx.cc b/src/cxx.cc
index 4aac64279..70ebc0b1f 100644
--- a/src/cxx.cc
+++ b/src/cxx.cc
@@ -1,4 +1,5 @@
 #include "../include/cxx.h"
+#include <cstdio>
 #include <cstring>
 #include <iostream>
 #include <memory>
@@ -76,8 +77,8 @@ inline namespace cxxbridge1 {
 template <typename Exception>
 void panic [[noreturn]] (const char *msg) {
 #if defined(RUST_CXX_NO_EXCEPTIONS)
-  std::cerr << "Error: " << msg << ". Aborting." << std::endl;
-  std::terminate();
+  std::fprintf(stderr, "Error: %s. Aborting.\n", msg);
+  std::abort();
 #else
   throw Exception(msg);
 #endif


Test patch: