5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

deprecated なメソッド呼び出しで警告が出ないようにする

Posted at
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// ここに deprecated なメソッドを呼び出すコード
#pragma clang diagnostic pop

マクロでやるなら _Pragma() が使えるようなので、

// Suppress deprecated warnings
#define OldCode(args)                                                  \
  _Pragma("clang diagnostic push")                                     \
  _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")    \
  args                                                                 \
  _Pragma("clang diagnostic pop")
#endif

OldCode({
  // ここに deprecated なメソッドを呼び出すコード
});
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?