Skip to content

Commit 2819fb1

Browse files
committed
Fixes for clang-cl
1 parent d7dbd9d commit 2819fb1

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

include/cpptrace/from_current_macros.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,33 @@
1717
#endif
1818

1919
#ifdef _MSC_VER
20+
#if defined(__clang__)
21+
#define CPPTRACE_PUSH_EXTENSION_WARNINGS \
22+
_Pragma("clang diagnostic push") \
23+
_Pragma("clang diagnostic ignored \"-Wlanguage-extension-token\"")
24+
#define CPPTRACE_POP_EXTENSION_WARNINGS \
25+
_Pragma("clang diagnostic pop")
26+
#else
27+
#define CPPTRACE_PUSH_EXTENSION_WARNINGS
28+
#define CPPTRACE_POP_EXTENSION_WARNINGS
29+
#endif
2030
#define CPPTRACE_TYPE_FOR(param) \
2131
typename ::cpptrace::detail::argument<void(param)>::type
2232
// this awful double-IILE is due to C2713 "You can't use structured exception handling (__try/__except) and C++
2333
// exception handling (try/catch) in the same function."
2434
#define CPPTRACE_TRY \
2535
try { \
2636
[&]() -> ::cpptrace::detail::dont_return_from_try_catch_macros { \
37+
CPPTRACE_PUSH_EXTENSION_WARNINGS \
2738
__try { \
39+
CPPTRACE_POP_EXTENSION_WARNINGS \
2840
return [&]() -> ::cpptrace::detail::dont_return_from_try_catch_macros {
2941
#define CPPTRACE_CATCH(param) \
3042
return ::cpptrace::detail::dont_return_from_try_catch_macros(); \
3143
}(); \
44+
CPPTRACE_PUSH_EXTENSION_WARNINGS \
3245
} __except(::cpptrace::detail::exception_filter<CPPTRACE_TYPE_FOR(param)>(GetExceptionInformation())) { \
46+
CPPTRACE_POP_EXTENSION_WARNINGS \
3347
CPPTRACE_UNREACHABLE(); \
3448
} \
3549
}(); \

src/binary/pe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace detail {
8484
} else {
8585
// 64 bit
8686
// I get an "error: 'QWORD' was not declared in this scope" for some reason when using QWORD
87-
auto bytes = load_bytes<unsigned __int64>(file, nt_header_offset + 0x18 + 0x18); // optional header + 0x18
87+
auto bytes = load_bytes<std::uint64_t>(file, nt_header_offset + 0x18 + 0x18); // optional header + 0x18
8888
if(!bytes) {
8989
return std::move(bytes).unwrap_error();
9090
}

src/from_current.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,17 @@ namespace detail {
8484
std::int32_t pCatchableTypeArray;
8585
};
8686
#pragma warning(disable:4200)
87+
#if IS_CLANG
88+
#pragma clang diagnostic push
89+
#pragma clang diagnostic ignored "-Wc99-extensions"
90+
#endif
8791
struct CatchableTypeArray {
8892
uint32_t nCatchableTypes;
8993
int32_t arrayOfCatchableTypes[];
9094
};
95+
#if IS_CLANG
96+
#pragma clang diagnostic pop
97+
#endif
9198
#pragma warning (pop)
9299
#pragma pack(pop)
93100
#else
@@ -563,6 +570,7 @@ CPPTRACE_BEGIN_NAMESPACE
563570
namespace detail {
564571
#ifdef _MSC_VER
565572
bool matches_exception(EXCEPTION_POINTERS* exception_ptrs, const std::type_info& type_info) {
573+
CPPTRACE_PUSH_EXTENSION_WARNINGS
566574
__try {
567575
auto* exception_record = exception_ptrs->ExceptionRecord;
568576
// Check if the SEH exception is a C++ exception
@@ -572,6 +580,7 @@ CPPTRACE_BEGIN_NAMESPACE
572580
} __except(EXCEPTION_EXECUTE_HANDLER) {
573581
// pass
574582
}
583+
CPPTRACE_POP_EXTENSION_WARNINGS
575584
return false;
576585
}
577586
#else

0 commit comments

Comments
 (0)