https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a4138329a14f75b2ab4fffed2d8fd24056a56db0

commit a4138329a14f75b2ab4fffed2d8fd24056a56db0
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Mon Apr 12 10:07:35 2021 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Apr 28 13:10:23 2021 +0200

    [CRT] Add macros to disable diagnostics from GCC and clang
    
    Instead of disabling them globally, this will help making finer grained 
decisions
---
 sdk/include/crt/crtdefs.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

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 */

Reply via email to