How do I define a macro with multiple pragmas for Clang?

后端 未结 2 593
伪装坚强ぢ
伪装坚强ぢ 2021-02-18 17:54

I\'d like to add some macros to ease (un)setting a specific warning around routines that we are deprecating internally.

I\'d like to turn this:

#pragma c         


        
2条回答
  •  Happy的楠姐
    2021-02-18 18:43

    You can use this solution:

    #define NS_SUPPRESS_DIRECT_USE(expr)   _Pragma("clang diagnostic push") \
                                           _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")\
                                           expr\
                                           _Pragma("clang diagnostic pop") 
    

    Then just add it:

    NS_SUPPRESS_DIRECT_USE(
                          Foo();
                          );
    

提交回复
热议问题