How to put a warning disable pragma inside a macro

2019-05-26 10:48发布

I need to disable a warning that originates inside the macro '__LOG_W' in following code. To do that, I wrapped this macro inside another macro 'LOG_W' and disabled the warning '-Wold-style-cast' with in that. Then in the code I used the LOG_W instead. However I still get the warning and unable to find out why. Any pointers appreciated.

#define LOG_W(expr)\
  _Pragma("GCC diagnostic push")\
  _Pragma("GCC diagnostic ignored \"-Wold-style-cast\"")\
  __LOG_W(DEF, UNKNOWN, expr);\
  _Pragma("GCC diagnostic pop")

0条回答
登录 后发表回答