diff options
| author | Martin Hořeňovský | 2025-12-01 14:18:54 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2025-12-02 14:01:55 +0100 |
| commit | 32eac2d1bb63d6b58a32e341e22b9438f1bd041a (patch) | |
| tree | ae6bce085b5422e93679c9b6d538451bb8e544d0 /src/catch2/internal/catch_run_context.cpp | |
| parent | e849735e11f23ce9ec819e053b107f2ec3c3c1c4 (diff) | |
| download | catch3-32eac2d1bb63d6b58a32e341e22b9438f1bd041a.tar.gz | |
Only use thread_local in builds with thread safety enabled
MSVC cannot dllexport thread_local variables, so we avoid making
globals thread local if we won't support multiple threads anyway.
Closes #3044
Diffstat (limited to 'src/catch2/internal/catch_run_context.cpp')
| -rw-r--r-- | src/catch2/internal/catch_run_context.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 3d72131d..7fce10da 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -20,6 +20,7 @@ #include <catch2/internal/catch_output_redirect.hpp> #include <catch2/internal/catch_assertion_handler.hpp> #include <catch2/internal/catch_test_failure_exception.hpp> +#include <catch2/internal/catch_thread_local.hpp> #include <catch2/internal/catch_result_type.hpp> #include <cassert> @@ -175,25 +176,25 @@ namespace Catch { // from heap, to avoid consuming too much thread-local storage. // This is used for the "if" part of CHECKED_IF/CHECKED_ELSE - static thread_local bool g_lastAssertionPassed = false; + static CATCH_INTERNAL_THREAD_LOCAL bool g_lastAssertionPassed = false; // This is the source location for last encountered macro. It is // used to provide the users with more precise location of error // when an unexpected exception/fatal error happens. - static thread_local SourceLineInfo g_lastKnownLineInfo("DummyLocation", static_cast<size_t>(-1)); + static CATCH_INTERNAL_THREAD_LOCAL SourceLineInfo g_lastKnownLineInfo("DummyLocation", static_cast<size_t>(-1)); // Should we clear message scopes before sending off the messages to // reporter? Set in `assertionPassedFastPath` to avoid doing the full // clear there for performance reasons. - static thread_local bool g_clearMessageScopes = false; + static CATCH_INTERNAL_THREAD_LOCAL bool g_clearMessageScopes = false; CATCH_INTERNAL_START_WARNINGS_SUPPRESSION CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS // Actual messages to be provided to the reporter - static thread_local std::vector<MessageInfo> g_messages; + static CATCH_INTERNAL_THREAD_LOCAL std::vector<MessageInfo> g_messages; // Owners for the UNSCOPED_X information macro - static thread_local std::vector<ScopedMessage> g_messageScopes; + static CATCH_INTERNAL_THREAD_LOCAL std::vector<ScopedMessage> g_messageScopes; CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION } // namespace Detail |