Reputation: 4622
I previously used such pragmas, which I seem to recall worked both with GCC (ubuntu) and clang (macos). They seem to be effective to suppress warning from header #include
s.
// test.cpp
struct [[deprecated]] Foo {};
#pragma clang push
#pragma clang ignored "-Wdeprecated-declarations"
int main() {
auto foo_fun = [](const Foo &f) {};
foo_fun(Foo());
}
#pragma clang pop
However, it does not seem to work when the deprecated type occurs as a lambda or plain function parameter, when compiled with clang -std=c++14 -o wat test.cpp
. The compiler version is Apple clang version 12.0.0 (clang-1200.0.32.29)
What do I do to suppress deprecation warning in these contexts?
Upvotes: 2
Views: 1513
Reputation: 2260
You are missing a diagnostic
keyword in your pragma declarations:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
...
#pragma clang diagnostic pop
Upvotes: 3