Hacker News new | past | comments | ask | show | jobs | submit login

-Wno-specific-warning (I think it's always had this, or at least for a very long time).



And:

  #pragma GCC diagnostic push
  #pragma GCC diagnostic warning "-Wspecific-warning"
  #pragma GCC diagnostic ignored "-Wspecific-warning"
  ...
  #pragma GCC diagnostic pop
For warnings you want to disable in a smaller scope. s/GCC/clang/ for clang. Bonus points:

  #define MM_WARNING_IGNORE_GCC(x)   MM_IF_GCC(   _Pragma(GCC   diagnostic ignored x) )
  #define MM_WARNING_IGNORE_CLANG(x) MM_IF_CLANG( _Pragma(clang diagnostic ignored x) )
  #define MM_WARNING_IGNORE_MSVC(x)  MM_IF_MSVC(  __pragma(warning(disable: x))       )
  #define MM_WARNING_PUSH() \
    IF_GCC(   _Pragma(GCC diagnostic push)   ) \
    IF_CLANG( _Pragma(clang diagnostic push) ) \
    IF_MSVC(  __pragma(warning(push))        )
  #define MM_WARNING_POP() \
    IF_GCC(   _Pragma(GCC diagnostic pop)   ) \
    IF_CLANG( _Pragma(clang diagnostic pop) ) \
    IF_MSVC(  __pragma(warning(pop))        )

  MM_WARNING_PUSH()
  MM_WARNING_IGNORE_GCC("-Wspecific-warning")
  MM_WARNING_IGNORE_CLANG("-Wspecific-warning")
  MM_WARNING_IGNORE_MSVC(1234)
  ...
  MM_WARNING_POP()
Defining MM_IF_*() is left as an exercise to the reader.


clang understands #pragma GCC diagnostic fine, no need to have special code for it.


Hmm. I could swear this wasn't the case in one of the build environments I ran into (possibly an older version of clang or something? or perhaps I'm thinking of some other non-diagnostic pragma...)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: