Advertisement
ulfben

Disable Warnings cross platforms

Oct 13th, 2020
1,873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement