Skip to content

Commit e64fbbd

Browse files
fix: appease MSVC linter by ignoring C4996 error code to ignore atomic shared ptr suggestion
1 parent 56c7420 commit e64fbbd

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

src/utils/diagnostics/diagnostic.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,38 @@ std::shared_ptr<const SinkList> g_sinks;
1515

1616
void set_diagnostic_sinks(std::span<const DiagnosticSink> sinks) noexcept {
1717
auto list = std::make_shared<SinkList>(sinks.begin(), sinks.end());
18-
std::atomic_store_explicit( // NOLINT deprecated-declarations
18+
19+
#ifdef _MSC_VER
20+
#pragma warning(push)
21+
#pragma warning(disable : 4996)
22+
#endif
23+
24+
std::atomic_store_explicit( // NOLINT(deprecated-declarations)
1925
&g_sinks,
2026
// the suggestion to use std::atomic::<std::shared_ptr<T>>
2127
std::shared_ptr<const SinkList>(
2228
std::move(list)), // This may not require a move
2329
std::memory_order_release);
2430
// lint from clang tidy does not work on msvc(it works on GCC, at least!), we
2531
// should look into this more! TODO
32+
33+
#ifdef _MSC_VER
34+
#pragma warning(pop)
35+
#endif
2636
}
2737

2838
std::shared_ptr<const SinkList> diagnostic_sinks_snapshot() noexcept {
29-
// NOLINTNEXTLINE (same as above)
30-
return std::atomic_load_explicit(std::addressof(g_sinks),
31-
std::memory_order_acquire);
39+
#ifdef _MSC_VER
40+
#pragma warning(push)
41+
#pragma warning(disable : 4996)
42+
#endif
43+
44+
return std::atomic_load_explicit( // NOLINT(deprecated-declarations)
45+
std::addressof(g_sinks), std::memory_order_acquire);
46+
47+
#ifdef _MSC_VER
48+
#pragma warning(pop)
49+
#endif
3250
}
3351

3452
void report(const DiagnosticEvent &e) noexcept {

0 commit comments

Comments
 (0)