VS2015 fixes (#165)

Fixes the compilation on VS14 / 2015.
This commit is contained in:
_BLU 2024-09-05 05:32:00 +02:00 committed by GitHub
parent 7fdbbfdf67
commit 0d89be4fbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 20 deletions

12
.gitignore vendored
View File

@ -1,9 +1,11 @@
.vscode .vscode/
.idea/
a.out a.out
build*/ build*/
repro*/ repro*/
__pycache__ __pycache__/
scratch scratch
.vscode tmp/
tmp bazel-*/
bazel-* cmake-build-*/

View File

@ -495,7 +495,7 @@ namespace cpptrace {
namespace detail { namespace detail {
std::atomic_bool absorb_trace_exceptions(true); // NOSONAR std::atomic_bool absorb_trace_exceptions(true); // NOSONAR
std::atomic_bool resolve_inlined_calls(true); // NOSONAR std::atomic_bool resolve_inlined_calls(true); // NOSONAR
std::atomic<enum cache_mode> cache_mode(cache_mode::prioritize_speed); // NOSONAR std::atomic<cache_mode> current_cache_mode(cache_mode::prioritize_speed); // NOSONAR
} }
void absorb_trace_exceptions(bool absorb) { void absorb_trace_exceptions(bool absorb) {
@ -508,7 +508,7 @@ namespace cpptrace {
namespace experimental { namespace experimental {
void set_cache_mode(cache_mode mode) { void set_cache_mode(cache_mode mode) {
detail::cache_mode = mode; detail::current_cache_mode = mode;
} }
} }
@ -521,8 +521,8 @@ namespace cpptrace {
return resolve_inlined_calls; return resolve_inlined_calls;
} }
enum cache_mode get_cache_mode() { cache_mode get_cache_mode() {
return cache_mode; return current_cache_mode;
} }
CPPTRACE_FORCE_NO_INLINE CPPTRACE_FORCE_NO_INLINE

View File

@ -40,7 +40,7 @@ namespace detail {
bool should_absorb_trace_exceptions(); bool should_absorb_trace_exceptions();
bool should_resolve_inlined_calls(); bool should_resolve_inlined_calls();
enum cache_mode get_cache_mode(); cache_mode get_cache_mode();
} }
} }

View File

@ -31,15 +31,15 @@ namespace detail {
// Lightweight std::source_location. // Lightweight std::source_location.
struct source_location { struct source_location {
const char* const file; const char* const file;
//const char* const function; // disabled for now due to static constexpr restrictions
const int line; const int line;
constexpr source_location( constexpr source_location(
//const char* _function /*= __builtin_FUNCTION()*/, const char* _file,
const char* _file = __builtin_FILE(), int _line
int _line = __builtin_LINE() ) : file(_file), line(_line) {}
) : file(_file), /*function(_function),*/ line(_line) {}
}; };
#define CPPTRACE_CURRENT_LOCATION ::cpptrace::detail::source_location(__FILE__, __LINE__)
enum class assert_type { enum class assert_type {
assert, assert,
verify, verify,
@ -117,7 +117,7 @@ namespace detail {
} }
// Check condition in both debug and release. std::runtime_error on failure. // Check condition in both debug and release. std::runtime_error on failure.
#define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, {}, ::cpptrace::detail::as_string(__VA_ARGS__))) #define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION, ::cpptrace::detail::as_string(__VA_ARGS__)))
template<typename T> template<typename T>
void assert_impl( void assert_impl(
@ -153,13 +153,13 @@ namespace detail {
// Check condition in both debug and release. std::runtime_error on failure. // Check condition in both debug and release. std::runtime_error on failure.
#define VERIFY(...) ( \ #define VERIFY(...) ( \
assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \ assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \
) )
#ifndef NDEBUG #ifndef NDEBUG
// Check condition in both debug. std::runtime_error on failure. // Check condition in both debug. std::runtime_error on failure.
#define ASSERT(...) ( \ #define ASSERT(...) ( \
assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \ assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \
) )
#else #else
// Check condition in both debug. std::runtime_error on failure. // Check condition in both debug. std::runtime_error on failure.

View File

@ -496,8 +496,10 @@ namespace detail {
template< template<
typename T, typename T,
typename D typename D
// workaround a msvc bug https://developercommunity.visualstudio.com/t/MSVC-1938331290-preview-fails-to-comp/10505565 // workaround for:
#if !defined(_MSC_VER) || _MSC_VER != 1938 // == 19.38-specific msvc bug https://developercommunity.visualstudio.com/t/MSVC-1938331290-preview-fails-to-comp/10505565
// <= 19.23 msvc also appears to fail (but for a different reason https://godbolt.org/z/6Y5EvdWPK)
#if !defined(_MSC_VER) || !(_MSC_VER <= 1923 || _MSC_VER == 1938)
, ,
typename std::enable_if< typename std::enable_if<
std::is_same<decltype(std::declval<D>()(std::declval<T>())), void>::value, std::is_same<decltype(std::declval<D>()(std::declval<T>())), void>::value,