diff --git a/sdk/include/crt/crtdefs.h b/sdk/include/crt/crtdefs.h index 0162e7a46de..8ea3f85bdf5 100644 --- a/sdk/include/crt/crtdefs.h +++ b/sdk/include/crt/crtdefs.h @@ -38,6 +38,10 @@ #define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value) #endif +#ifndef _CRT_DEFER_MACRO +#define _CRT_DEFER_MACRO(M,...) M(__VA_ARGS__) +#endif + #ifndef _CRT_WIDE #define __CRT_WIDE(_String) L ## _String #define _CRT_WIDE(_String) __CRT_WIDE(_String) @@ -440,4 +444,25 @@ typedef struct localeinfo_struct { #pragma pack(pop) +/* GCC-style diagnostics */ +#ifndef PRAGMA_DIAGNOSTIC_IGNORED +# ifdef __clang__ +# define PRAGMA_DIAGNOSTIC_PUSH() _Pragma("clang diagnostic push") +# define PRAGMA_DIAGNOSTIC_IGNORED(__x) \ + _Pragma(_CRT_STRINGIZE(clang diagnostic ignored _CRT_DEFER_MACRO(_CRT_STRINGIZE,__x))) +# define PRAGMA_DIAGNOSTIC_POP() _Pragma("clang diagnostic pop") +# elif defined (__GNUC__) +# define PRAGMA_DIAGNOSTIC_PUSH() _Pragma("GCC diagnostic push") +# define PRAGMA_DIAGNOSTIC_IGNORED(__x) \ + _Pragma("GCC diagnostic ignored \"-Wpragmas\"") /* This allows us to use it for unkonwn warnings */ \ + _Pragma(_CRT_STRINGIZE(GCC diagnostic ignored _CRT_DEFER_MACRO(_CRT_STRINGIZE,__x))) \ + _Pragma("GCC diagnostic error \"-Wpragmas\"") /* This makes sure that we don't have side effects because we disabled it for our own use. This will be popped anyway. */ +# define PRAGMA_DIAGNOSTIC_POP() _Pragma("GCC diagnostic pop") +# else +# define PRAGMA_DIAGNOSTIC_PUSH() +# define PRAGMA_DIAGNOSTIC_IGNORED(__x) +# define PRAGMA_DIAGNOSTIC_POP() +# endif +#endif + #endif /* !_INC_CRTDEFS */