Skip to content

Commit b1c9466

Browse files
authored
Suppress clang warning "ATOMIC_FLAG_INIT marked deprecated" (#1502)
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.
1 parent c720204 commit b1c9466

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

tdutils/td/utils/SpinLock.h

+3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ class SpinLock {
6363
}
6464

6565
private:
66+
#pragma clang diagnostic push
67+
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
6668
std::atomic_flag flag_ = ATOMIC_FLAG_INIT;
69+
#pragma clang diagnostic pop
6770
void unlock() {
6871
flag_.clear(std::memory_order_release);
6972
}

tdutils/td/utils/logging.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ void TsCerr::enterCritical() {
176176
void TsCerr::exitCritical() {
177177
lock_.clear(std::memory_order_release);
178178
}
179+
#pragma clang diagnostic push
180+
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
179181
TsCerr::Lock TsCerr::lock_ = ATOMIC_FLAG_INIT;
182+
#pragma clang diagnostic pop
180183

181184
class DefaultLog : public LogInterface {
182185
public:

tdutils/td/utils/logging.h

+3
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ class TsLog : public LogInterface {
343343

344344
private:
345345
LogInterface *log_ = nullptr;
346+
#pragma clang diagnostic push
347+
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
346348
std::atomic_flag lock_ = ATOMIC_FLAG_INIT;
349+
#pragma clang diagnostic pop
347350
void enter_critical() {
348351
while (lock_.test_and_set(std::memory_order_acquire)) {
349352
// spin

tdutils/td/utils/port/detail/PollableFd.h

+3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ class PollableFdInfo : private ListNode {
149149

150150
private:
151151
NativeFd fd_{};
152+
#pragma clang diagnostic push
153+
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
152154
std::atomic_flag lock_ = ATOMIC_FLAG_INIT;
155+
#pragma clang diagnostic pop
153156
PollFlagsSet flags_;
154157
#if TD_PORT_WINDOWS
155158
SpinLock observer_lock_;

0 commit comments

Comments
 (0)