-
-
Notifications
You must be signed in to change notification settings - Fork 134
adds experimental support for C++20 modules #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
967964c
ded6ca9
1a0454c
c73cceb
6c27579
d3d6bdc
25a75dc
2375e9f
af8b2db
190a07e
a6f5018
0a8c500
ec9f31c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export module cpptrace; | ||
|
||
int main() | ||
|
||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef CPPTRACE_EXCEPTIONS_MACROS_HPP | ||
#define CPPTRACE_EXCEPTIONS_MACROS_HPP | ||
|
||
// Exception wrapper utilities | ||
#define CPPTRACE_WRAP_BLOCK(statements) do { \ | ||
try { \ | ||
statements \ | ||
} catch(...) { \ | ||
::cpptrace::rethrow_and_wrap_if_needed(); \ | ||
} \ | ||
} while(0) | ||
|
||
#define CPPTRACE_WRAP(expression) [&] () -> decltype((expression)) { \ | ||
try { \ | ||
return expression; \ | ||
} catch(...) { \ | ||
::cpptrace::rethrow_and_wrap_if_needed(1); \ | ||
} \ | ||
} () | ||
|
||
#endif // CPPTRACE_EXCEPTIONS_MACROS_HPP |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef CPPTRACE_FROM_CURRENT_MACROS_HPP | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, is there a sensible way to make either of the following work instead of a new macros header? #include <cpptrace/from_current.hpp>
import cpptrace;
// or
import cpptrace;
#include <cpptrace/from_current.hpp> If a macros header is the best way to do this I think it's good with me - and I'm guessing if so other libraries might follow the same pattern. But I'd love to be able to keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do the former, but not the latter (yet). Having said that, including #include <cpptrace/from_current_macros.hpp>
import cpptrace; Once support for modules stabilises, I'd recommend the docs encourage header users not include the |
||
#define CPPTRACE_FROM_CURRENT_MACROS_HPP | ||
|
||
// https://godbolt.org/z/4MsT6KqP1 | ||
#ifdef _MSC_VER | ||
#define CPPTRACE_UNREACHABLE() __assume(false) | ||
#else | ||
#define CPPTRACE_UNREACHABLE() __builtin_unreachable() | ||
#endif | ||
|
||
// https://godbolt.org/z/7neGPEche | ||
// gcc added support in 4.8 but I'm too lazy to check the minor version | ||
#if defined(__GNUC__) && (__GNUC__ < 5) | ||
#define CPPTRACE_NORETURN __attribute__((noreturn)) | ||
#else | ||
#define CPPTRACE_NORETURN [[noreturn]] | ||
#endif | ||
|
||
#ifdef _MSC_VER | ||
#define CPPTRACE_TYPE_FOR(param) \ | ||
::cpptrace::detail::argument<void(param)>::type | ||
// this awful double-IILE is due to C2713 "You can't use structured exception handling (__try/__except) and C++ | ||
// exception handling (try/catch) in the same function." | ||
#define CPPTRACE_TRY \ | ||
try { \ | ||
[&]() { \ | ||
__try { \ | ||
[&]() { | ||
#define CPPTRACE_CATCH(param) \ | ||
}(); \ | ||
} __except(::cpptrace::detail::exception_filter<CPPTRACE_TYPE_FOR(param)>(GetExceptionInformation())) {} \ | ||
}(); \ | ||
} catch(param) | ||
#else | ||
#define CPPTRACE_UNWIND_INTERCEPTOR_FOR(param) \ | ||
::cpptrace::detail::unwind_interceptor_for<void(param)> | ||
#define CPPTRACE_TRY \ | ||
try { \ | ||
try { | ||
#define CPPTRACE_CATCH(param) \ | ||
} catch(const CPPTRACE_UNWIND_INTERCEPTOR_FOR(param)&) { \ | ||
CPPTRACE_UNREACHABLE(); \ | ||
/* force instantiation of the init-er */ \ | ||
::cpptrace::detail::nop(CPPTRACE_UNWIND_INTERCEPTOR_FOR(param)::init); \ | ||
} \ | ||
} catch(param) | ||
#endif | ||
|
||
#ifdef CPPTRACE_UNPREFIXED_TRY_CATCH | ||
#define TRY CPPTRACE_TRY | ||
#define CATCH(param) CPPTRACE_CATCH(param) | ||
#endif | ||
|
||
#endif // CPPTRACE_FROM_CURRENT_MACROS_HPP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with this option but I'll trust this does something reasonable :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This installs the module interface unit :)