From ec7abcdf68009f00c51fc6e2ab8ec6408b786b15 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Mon, 26 Dec 2016 22:11:23 +0300 Subject: [PATCH] Fixed MacOS examples --- example/assert_handler.cpp | 1 + example/terminate_handler.cpp | 7 ++++--- include/boost/stacktrace/detail/backend_linux.hpp | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example/assert_handler.cpp b/example/assert_handler.cpp index 4ff928c..8c62f6b 100644 --- a/example/assert_handler.cpp +++ b/example/assert_handler.cpp @@ -6,6 +6,7 @@ #define BOOST_ENABLE_ASSERT_HANDLER +#include // std::exit #include BOOST_NOINLINE void foo(int i); BOOST_NOINLINE void bar(int i); diff --git a/example/terminate_handler.cpp b/example/terminate_handler.cpp index 0d6d27d..c115352 100644 --- a/example/terminate_handler.cpp +++ b/example/terminate_handler.cpp @@ -21,8 +21,8 @@ BOOST_NOINLINE void foo(int i) { bar(--i); } -inline void ignore_exit(int){ std::exit(0); } -#define _Exit ignore_exit +// Ignoring _Exit for testing purposes +#define _Exit(x) exit(x+1) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -30,6 +30,7 @@ inline void ignore_exit(int){ std::exit(0); } #include // std::set_terminate, std::abort #include // ::signal +#include // std::_Exit #include #include // std::cerr @@ -44,7 +45,7 @@ void my_signal_handler(int signum) { if (bt) { std::cerr << "Signal " << signum << ", backtrace:\n" << boost::stacktrace::stacktrace() << '\n'; // ``[footnote Strictly speaking this code is not async-signal-safe, because it uses std::cerr. [link boost_stacktrace.build_macros_and_backends Section "Build, Macros and Backends"] describes async-signal-safe backends, so if you will use the noop backend code becomes absolutely valid as that backens always returns 0 frames and `operator<<` will be never called. ]`` } - _Exit(-1); + std::_Exit(-1); } //] diff --git a/include/boost/stacktrace/detail/backend_linux.hpp b/include/boost/stacktrace/detail/backend_linux.hpp index 124fd8a..8179cb2 100644 --- a/include/boost/stacktrace/detail/backend_linux.hpp +++ b/include/boost/stacktrace/detail/backend_linux.hpp @@ -22,6 +22,7 @@ #endif #include +#include #include #include