From 1397ff33fecef334a421a9b6a74bd6a6bb2f6f9c Mon Sep 17 00:00:00 2001 From: tolk-vm Date: Mon, 27 Jan 2025 17:02:09 +0300 Subject: [PATCH] Suppress clang warning "ATOMIC_FLAG_INIT marked deprecated" In C++20, macro 'ATOMIC_FLAG_INIT' has been marked as deprecated. We need still to use it to be able to compile for C++17. For now, just suppress this warning. --- tdutils/td/utils/SpinLock.h | 3 +++ tdutils/td/utils/logging.cpp | 3 +++ tdutils/td/utils/logging.h | 3 +++ tdutils/td/utils/port/detail/PollableFd.h | 3 +++ 4 files changed, 12 insertions(+) diff --git a/tdutils/td/utils/SpinLock.h b/tdutils/td/utils/SpinLock.h index b5bb62dbf..f0856f0c0 100644 --- a/tdutils/td/utils/SpinLock.h +++ b/tdutils/td/utils/SpinLock.h @@ -63,7 +63,10 @@ class SpinLock { } private: +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-pragma" std::atomic_flag flag_ = ATOMIC_FLAG_INIT; +#pragma clang diagnostic pop void unlock() { flag_.clear(std::memory_order_release); } diff --git a/tdutils/td/utils/logging.cpp b/tdutils/td/utils/logging.cpp index 345615f12..03d32ee2c 100644 --- a/tdutils/td/utils/logging.cpp +++ b/tdutils/td/utils/logging.cpp @@ -176,7 +176,10 @@ void TsCerr::enterCritical() { void TsCerr::exitCritical() { lock_.clear(std::memory_order_release); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-pragma" TsCerr::Lock TsCerr::lock_ = ATOMIC_FLAG_INIT; +#pragma clang diagnostic pop class DefaultLog : public LogInterface { public: diff --git a/tdutils/td/utils/logging.h b/tdutils/td/utils/logging.h index 5c9a0621f..dbf4c64b3 100644 --- a/tdutils/td/utils/logging.h +++ b/tdutils/td/utils/logging.h @@ -343,7 +343,10 @@ class TsLog : public LogInterface { private: LogInterface *log_ = nullptr; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-pragma" std::atomic_flag lock_ = ATOMIC_FLAG_INIT; +#pragma clang diagnostic pop void enter_critical() { while (lock_.test_and_set(std::memory_order_acquire)) { // spin diff --git a/tdutils/td/utils/port/detail/PollableFd.h b/tdutils/td/utils/port/detail/PollableFd.h index dceea4f38..6cb621e82 100644 --- a/tdutils/td/utils/port/detail/PollableFd.h +++ b/tdutils/td/utils/port/detail/PollableFd.h @@ -149,7 +149,10 @@ class PollableFdInfo : private ListNode { private: NativeFd fd_{}; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-pragma" std::atomic_flag lock_ = ATOMIC_FLAG_INIT; +#pragma clang diagnostic pop PollFlagsSet flags_; #if TD_PORT_WINDOWS SpinLock observer_lock_;