ulfben

Disable Warnings cross platforms

Oct 13th, 2020
566
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #if defined(_MSC_VER)
  2.     #define DISABLE_WARNING_PUSH           __pragma(warning( push ))
  3.     #define DISABLE_WARNING_POP            __pragma(warning( pop ))
  4.     #define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))
  5.  
  6.     #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER    DISABLE_WARNING(4100)
  7.     #define DISABLE_WARNING_UNREFERENCED_FUNCTION            DISABLE_WARNING(4505)
  8.     // other warnings you want to deactivate...
  9.    
  10. #elif defined(__GNUC__) || defined(__clang__)
  11.     #define DO_PRAGMA(X) _Pragma(#X)
  12.     #define DISABLE_WARNING_PUSH           DO_PRAGMA(GCC diagnostic push)
  13.     #define DISABLE_WARNING_POP            DO_PRAGMA(GCC diagnostic pop)
  14.     #define DISABLE_WARNING(warningName)   DO_PRAGMA(GCC diagnostic ignored #warningName)
  15.    
  16.     #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER    DISABLE_WARNING(-Wunused-parameter)
  17.     #define DISABLE_WARNING_UNREFERENCED_FUNCTION            DISABLE_WARNING(-Wunused-function)
  18.    // other warnings you want to deactivate...
  19.    
  20. #else
  21.     #define DISABLE_WARNING_PUSH
  22.     #define DISABLE_WARNING_POP
  23.     #define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER
  24.     #define DISABLE_WARNING_UNREFERENCED_FUNCTION
  25.     // other warnings you want to deactivate...
  26.  
  27. #endif
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×