Go to the documentation of this file.
11 #ifndef __SYS_PRAGMA_H_INCLUDED__
12 #define __SYS_PRAGMA_H_INCLUDED__
18 # define SYS_PRAGMA(X) __pragma(X)
19 #elif defined(__GNUC__)
20 # define SYS_PRAGMA(X) _Pragma(#X)
22 # define SYS_PRAGMA(X)
28 # define SYS_PRAGMA_PUSH_WARN() SYS_PRAGMA(warning(push))
29 # define SYS_PRAGMA_POP_WARN() SYS_PRAGMA(warning(pop))
30 #elif SYS_IS_GCC_GE(4, 6) || defined(__clang__)
31 # define SYS_PRAGMA_PUSH_WARN() SYS_PRAGMA(GCC diagnostic push)
32 # define SYS_PRAGMA_POP_WARN() SYS_PRAGMA(GCC diagnostic pop)
34 # define SYS_PRAGMA_PUSH_WARN()
35 # define SYS_PRAGMA_POP_WARN()
41 #if SYS_IS_GCC_GE(4, 2) || defined(__clang__)
42 # define SYS_PRAGMA_DISABLE_DEPRECATED() \
43 SYS_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
44 #elif defined(_MSC_VER)
45 # define SYS_PRAGMA_DISABLE_DEPRECATED() \
46 SYS_PRAGMA(warning(disable: 4996))
48 # define SYS_PRAGMA_DISABLE_DEPRECATED()
50 #if defined(__clang__)
51 # define SYS_PRAGMA_DISABLE_DEPRECATED_COPY_DTOR() \
52 SYS_PRAGMA(clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-dtor")
54 # define SYS_PRAGMA_DISABLE_DEPRECATED_COPY_DTOR()
57 # define SYS_PRAGMA_DISABLE_OVERLOADED_VIRTUAL() \
58 SYS_PRAGMA(warning(disable: 4263)) \
59 SYS_PRAGMA(warning(disable: 4266)) \
61 #elif SYS_IS_GCC_GE(4, 6) || defined(__clang__)
62 # define SYS_PRAGMA_DISABLE_OVERLOADED_VIRTUAL() \
63 SYS_PRAGMA(GCC diagnostic ignored "-Woverloaded-virtual")
65 # define SYS_PRAGMA_DISABLE_OVERLOADED_VIRTUAL()
67 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
68 # define SYS_PRAGMA_DISABLE_IGNORED_QUALIFIERS() \
69 SYS_PRAGMA(GCC diagnostic ignored "-Wignored-qualifiers")
71 # define SYS_PRAGMA_DISABLE_IGNORED_QUALIFIERS()
73 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
74 # define SYS_PRAGMA_DISABLE_UNUSED_FUNCTION() \
75 SYS_PRAGMA(GCC diagnostic ignored "-Wunused-function")
77 # define SYS_PRAGMA_DISABLE_UNUSED_FUNCTION()
79 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
80 # define SYS_PRAGMA_DISABLE_UNUSED_VALUE() \
81 SYS_PRAGMA(GCC diagnostic ignored "-Wunused-value")
83 # define SYS_PRAGMA_DISABLE_UNUSED_VALUE()
85 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
86 # define SYS_PRAGMA_DISABLE_UNUSED_VARIABLE() \
87 SYS_PRAGMA(GCC diagnostic ignored "-Wunused-variable")
89 # define SYS_PRAGMA_DISABLE_UNUSED_VARIABLE()
91 #if SYS_IS_GCC_GE(4, 6)
92 # define SYS_PRAGMA_DISABLE_UNUSED_BUT_SET_VARIABLE() \
93 SYS_PRAGMA(GCC diagnostic ignored "-Wunused-but-set-variable")
94 #elif defined(_MSC_VER)
95 # define SYS_PRAGMA_DISABLE_UNUSED_BUT_SET_VARIABLE() \
96 SYS_PRAGMA(warning(disable: 4189))
98 # define SYS_PRAGMA_DISABLE_UNUSED_BUT_SET_VARIABLE()
100 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
101 # define SYS_PRAGMA_DISABLE_COMMENT_WARNING() \
102 SYS_PRAGMA(GCC diagnostic ignored "-Wcomment")
104 # define SYS_PRAGMA_DISABLE_COMMENT_WARNING()
106 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
107 # define SYS_PRAGMA_DISABLE_MISSING_FIELD_INITIALIZERS() \
108 SYS_PRAGMA(GCC diagnostic ignored "-Wmissing-field-initializers")
110 # define SYS_PRAGMA_DISABLE_MISSING_FIELD_INITIALIZERS()
112 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
113 # define SYS_PRAGMA_DISABLE_NON_VIRTUAL_DTOR() \
114 SYS_PRAGMA(GCC diagnostic ignored "-Wnon-virtual-dtor")
116 # define SYS_PRAGMA_DISABLE_NON_VIRTUAL_DTOR() \
117 SYS_PRAGMA(warning(disable: 4265))
119 #if SYS_IS_GCC_GE(4, 6) || SYS_IS_CLANG_GE(13, 0)
120 # define SYS_PRAGMA_DISABLE_FREE_NONHEAP_OBJECT() \
121 SYS_PRAGMA(GCC diagnostic ignored "-Wfree-nonheap-object")
123 # define SYS_PRAGMA_DISABLE_FREE_NONHEAP_OBJECT()
126 #if SYS_IS_GCC_GE(4, 8) && !defined(__clang__)
127 # define SYS_PRAGMA_DISABLE_INVALID_OFFSETOF() \
128 SYS_PRAGMA(GCC diagnostic ignored "-Winvalid-offsetof")
130 # define SYS_PRAGMA_DISABLE_INVALID_OFFSETOF()
133 #if defined(__clang__)
134 # define SYS_PRAGMA_DISABLE_INCONSISTENT_OVERRIDE() \
135 SYS_PRAGMA(GCC diagnostic ignored "-Winconsistent-missing-override")
137 # define SYS_PRAGMA_DISABLE_INCONSISTENT_OVERRIDE()
140 #if SYS_IS_GCC_GE(4, 8) && !defined(__clang__)
141 # define SYS_PRAGMA_DISABLE_MAYBE_UNINITIALIZED() \
142 SYS_PRAGMA(GCC diagnostic ignored "-Wmaybe-uninitialized")
144 # define SYS_PRAGMA_DISABLE_MAYBE_UNINITIALIZED()
147 #if SYS_IS_GCC_GE(4, 8) && !defined(__clang__)
148 # define SYS_PRAGMA_DISABLE_UNINITIALIZED() \
149 SYS_PRAGMA(GCC diagnostic ignored "-Wuninitialized")
151 # define SYS_PRAGMA_DISABLE_UNINITIALIZED()
154 #if defined(__clang__)
155 # define SYS_PRAGMA_DISABLE_VARARGS() \
156 SYS_PRAGMA(GCC diagnostic ignored "-Wvarargs")
158 # define SYS_PRAGMA_DISABLE_VARARGS()
164 #if SYS_IS_GCC_GE(4, 8) && !defined(__clang__)
165 # define SYS_PRAGMA_DISABLE_ATTRIBUTES() \
166 SYS_PRAGMA(GCC diagnostic ignored "-Wattributes")
168 # define SYS_PRAGMA_DISABLE_ATTRIBUTES()
171 #if SYS_IS_CLANG_GE(10, 0)
172 # define SYS_PRAGMA_DISABLE_SUGGEST_OVERRIDE() \
173 SYS_PRAGMA(GCC diagnostic ignored "-Wsuggest-override") \
174 SYS_PRAGMA(GCC diagnostic ignored "-Wsuggest-destructor-override")
175 #elif SYS_IS_GCC_GE(5, 0)
176 # define SYS_PRAGMA_DISABLE_SUGGEST_OVERRIDE() \
177 SYS_PRAGMA(GCC diagnostic ignored "-Wsuggest-override")
179 # define SYS_PRAGMA_DISABLE_SUGGEST_OVERRIDE()
182 #if SYS_IS_GCC_GE(8, 0) && !defined(__clang__)
183 # define SYS_PRAGMA_DISABLE_ALLOC_SIZE_LARGER_THAN() \
184 SYS_PRAGMA(GCC diagnostic ignored "-Walloc-size-larger-than=")
186 # define SYS_PRAGMA_DISABLE_ALLOC_SIZE_LARGER_THAN()
189 #if SYS_IS_GCC_GE(11, 0) && !defined(__clang__)
190 # define SYS_PRAGMA_DISABLE_MISMATCHED_NEW_DELETE() \
191 SYS_PRAGMA(GCC diagnostic ignored "-Wmismatched-new-delete")
193 # define SYS_PRAGMA_DISABLE_MISMATCHED_NEW_DELETE()
196 #if SYS_IS_GCC_GE(11, 0) && !defined(__clang__)
197 # define SYS_PRAGMA_DISABLE_NON_NULL() \
198 SYS_PRAGMA(GCC diagnostic ignored "-Wnonnull")
200 # define SYS_PRAGMA_DISABLE_NON_NULL()
203 #endif // __SYS_PRAGMA_H_INCLUDED__