2

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 #includes.

// 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?

1 Answer 1

3

You are missing a diagnostic keyword in your pragma declarations:

#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" ... #pragma clang diagnostic pop 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.