jeremy-rifkin / cpptrace

Simple, portable, and self-contained stacktrace library for C++11 and newer
MIT License
621 stars 64 forks source link

Missing cxxabi.h include when compiling on Windows with libc++ #121

Closed ChewyGumball closed 3 months ago

ChewyGumball commented 3 months ago

The cxxabi.h header is not used on Windows when using the Microsoft C++ runtime. Most people build with the Microsoft STL when building on Windows, but I am using libc++, and I have found that the protection against including cxxabi.h doesn't work in this case:

https://github.com/jeremy-rifkin/cpptrace/blob/d2b940ab07521df8baeff0fbf7aea68d94dffc65/src/utils/exception_type.hpp#L7 and https://github.com/jeremy-rifkin/cpptrace/blob/d2b940ab07521df8baeff0fbf7aea68d94dffc65/src/utils/exception_type.hpp#L16

My guess is that they are meant to be evaluated as: defined(CPPTRACE_HAS_CXX_EXCEPTION_TYPE) && defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_LIBCPP_VERSION but the preprocessor operator precedence makes it evaluated as: defined(CPPTRACE_HAS_CXX_EXCEPTION_TYPE) && defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_LIBCPP_VERSION)

Since I am using libc++, _LIBCPP_VERSION is defined, which means I get a compile error because it can't find cxxabi.h, even though CPPTRACE_HAS_CXX_EXCEPTION_TYPE is not defined.

Is this the correct interpretation of what the #if is meant to check, and if so, would making the precedence of operations explicit in these expressions be the best way to solve the issue?

jeremy-rifkin commented 3 months ago

Thanks for the report

jeremy-rifkin commented 3 months ago

I've released v0.6.0 which includes the fix for this