Antony Polukhin via Boost wrote:
template <class E> void throw_with_trace(const E& e) { throw boost::enable_error_info(e) << traced(boost::stacktrace::stacktrace()); }
Here no COM or <windows.h> code is needed, but there's no way to avoid their inclusion.
How it could be done?
std::thread has no constructor from std::thread::native_handle_t and I'd like to follow that pattern. If you've done something using
By splitting stacktrace.hpp and frame.hpp into two headers, one with the parts that do not need <windows.h>, the other with the rest. The code above would then be able to only include the first header. Picking some names at random, stacktrace.hpp stacktrace_def.hpp stacktrace_impl.hpp frame.hpp frame_def.hpp frame_impl.hpp stacktrace_def.hpp frame_def.hpp stacktrace_impl.hpp frame_impl.hpp although currently stacktrace has no impl parts, so it could be simplified to stacktrace.hpp stacktrace_def.hpp frame_impl.hpp stacktrace_def.hpp frame_def.hpp frame.hpp frame_def.hpp frame_impl.hpp platform specific methods - you're on your own. This makes no sense to me, especially since frame is constructible from void const*. stacktrace is just an array of frames.