From b9cbcb48be310c8e655eb527f417a393d83ca635 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 17 Nov 2016 22:39:06 +0300 Subject: [PATCH] Fix Windows compilation and improve examples --- example/getting_started.cpp | 2 +- example/throwing_st.cpp | 4 ++-- include/boost/stacktrace/detail/backtrace_holder_windows.hpp | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/example/getting_started.cpp b/example/getting_started.cpp index c8a80f1..4b422c0 100644 --- a/example/getting_started.cpp +++ b/example/getting_started.cpp @@ -72,7 +72,7 @@ namespace boost { void assertion_failed_msg(char const* expr, char const* msg, char const* function, char const* file, long line) { std::cerr << "Expression '" << expr << "' is false in function '" << function << "': " << (msg ? msg : "<...>") << ".\n" << "Backtrace:\n" << boost::stacktrace::stacktrace() << '\n'; - throw std::logic_error("assertion"); + std::abort(); } void assertion_failed(char const* expr, char const* function, char const* file, long line) { diff --git a/example/throwing_st.cpp b/example/throwing_st.cpp index 3a41814..3c23e07 100644 --- a/example/throwing_st.cpp +++ b/example/throwing_st.cpp @@ -41,12 +41,12 @@ struct with_trace : public Exception, public traced { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -BOOST_NOINLINE void oops(std::size_t i); +BOOST_NOINLINE void oops(int i); BOOST_NOINLINE void foo(int i); BOOST_NOINLINE void bar(int i); #include -BOOST_NOINLINE void oops(std::size_t i) { +BOOST_NOINLINE void oops(int i) { //[getting_started_throwing_with_trace if (i >= 4) throw with_trace("'i' must be less than 4 in oops()"); diff --git a/include/boost/stacktrace/detail/backtrace_holder_windows.hpp b/include/boost/stacktrace/detail/backtrace_holder_windows.hpp index 25df391..1f66716 100644 --- a/include/boost/stacktrace/detail/backtrace_holder_windows.hpp +++ b/include/boost/stacktrace/detail/backtrace_holder_windows.hpp @@ -122,7 +122,8 @@ struct backtrace_holder { inline std::size_t get_source_line(std::size_t frame) const BOOST_NOEXCEPT { ULONG line_num = 0; - if (!try_init_com()) { + com_holder idebug_; + if (!try_init_com(idebug_)) { return 0; }