Skip to content

Commit 0d89be4

Browse files
authored
VS2015 fixes (#165)
Fixes the compilation on VS14 / 2015.
1 parent 7fdbbfd commit 0d89be4

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
.vscode
1+
.vscode/
2+
.idea/
3+
24
a.out
35
build*/
46
repro*/
5-
__pycache__
7+
__pycache__/
68
scratch
7-
.vscode
8-
tmp
9-
bazel-*
9+
tmp/
10+
bazel-*/
11+
cmake-build-*/

src/cpptrace.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ namespace cpptrace {
495495
namespace detail {
496496
std::atomic_bool absorb_trace_exceptions(true); // NOSONAR
497497
std::atomic_bool resolve_inlined_calls(true); // NOSONAR
498-
std::atomic<enum cache_mode> cache_mode(cache_mode::prioritize_speed); // NOSONAR
498+
std::atomic<cache_mode> current_cache_mode(cache_mode::prioritize_speed); // NOSONAR
499499
}
500500

501501
void absorb_trace_exceptions(bool absorb) {
@@ -508,7 +508,7 @@ namespace cpptrace {
508508

509509
namespace experimental {
510510
void set_cache_mode(cache_mode mode) {
511-
detail::cache_mode = mode;
511+
detail::current_cache_mode = mode;
512512
}
513513
}
514514

@@ -521,8 +521,8 @@ namespace cpptrace {
521521
return resolve_inlined_calls;
522522
}
523523

524-
enum cache_mode get_cache_mode() {
525-
return cache_mode;
524+
cache_mode get_cache_mode() {
525+
return current_cache_mode;
526526
}
527527

528528
CPPTRACE_FORCE_NO_INLINE

src/utils/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace detail {
4040

4141
bool should_absorb_trace_exceptions();
4242
bool should_resolve_inlined_calls();
43-
enum cache_mode get_cache_mode();
43+
cache_mode get_cache_mode();
4444
}
4545
}
4646

src/utils/error.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ namespace detail {
3131
// Lightweight std::source_location.
3232
struct source_location {
3333
const char* const file;
34-
//const char* const function; // disabled for now due to static constexpr restrictions
3534
const int line;
3635
constexpr source_location(
37-
//const char* _function /*= __builtin_FUNCTION()*/,
38-
const char* _file = __builtin_FILE(),
39-
int _line = __builtin_LINE()
40-
) : file(_file), /*function(_function),*/ line(_line) {}
36+
const char* _file,
37+
int _line
38+
) : file(_file), line(_line) {}
4139
};
4240

41+
#define CPPTRACE_CURRENT_LOCATION ::cpptrace::detail::source_location(__FILE__, __LINE__)
42+
4343
enum class assert_type {
4444
assert,
4545
verify,
@@ -117,7 +117,7 @@ namespace detail {
117117
}
118118

119119
// Check condition in both debug and release. std::runtime_error on failure.
120-
#define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, {}, ::cpptrace::detail::as_string(__VA_ARGS__)))
120+
#define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION, ::cpptrace::detail::as_string(__VA_ARGS__)))
121121

122122
template<typename T>
123123
void assert_impl(
@@ -153,13 +153,13 @@ namespace detail {
153153

154154
// Check condition in both debug and release. std::runtime_error on failure.
155155
#define VERIFY(...) ( \
156-
assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \
156+
assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \
157157
)
158158

159159
#ifndef NDEBUG
160160
// Check condition in both debug. std::runtime_error on failure.
161161
#define ASSERT(...) ( \
162-
assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \
162+
assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \
163163
)
164164
#else
165165
// Check condition in both debug. std::runtime_error on failure.

src/utils/utils.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,10 @@ namespace detail {
496496
template<
497497
typename T,
498498
typename D
499-
// workaround a msvc bug https://developercommunity.visualstudio.com/t/MSVC-1938331290-preview-fails-to-comp/10505565
500-
#if !defined(_MSC_VER) || _MSC_VER != 1938
499+
// workaround for:
500+
// == 19.38-specific msvc bug https://developercommunity.visualstudio.com/t/MSVC-1938331290-preview-fails-to-comp/10505565
501+
// <= 19.23 msvc also appears to fail (but for a different reason https://godbolt.org/z/6Y5EvdWPK)
502+
#if !defined(_MSC_VER) || !(_MSC_VER <= 1923 || _MSC_VER == 1938)
501503
,
502504
typename std::enable_if<
503505
std::is_same<decltype(std::declval<D>()(std::declval<T>())), void>::value,

0 commit comments

Comments
 (0)