All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pragmas.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_BASE_ARCH_PRAGMAS_H
8#define PXR_BASE_ARCH_PRAGMAS_H
9
16
17#include "pxr/base/arch/defines.h"
18
19#if defined(ARCH_COMPILER_GCC)
20
21 #define ARCH_PRAGMA_PUSH \
22 _Pragma("GCC diagnostic push")
23
24 #define ARCH_PRAGMA_POP \
25 _Pragma("GCC diagnostic pop")
26
27 #define ARCH_PRAGMA(x) _Pragma(#x)
28
29 #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
30 ARCH_PRAGMA(push_macro(#macro_name))
31
32 #define ARCH_PRAGMA_POP_MACRO(macro_name) \
33 ARCH_PRAGMA(pop_macro(#macro_name))
34
35 // Convert errors about variables that may be used before initialization
36 // into warnings.
37 //
38 // This works around GCC bug 47679.
39 #define ARCH_PRAGMA_MAYBE_UNINITIALIZED \
40 _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
41
42 #define ARCH_PRAGMA_MACRO_REDEFINITION \
43 _Pragma("GCC diagnostic ignored \"-Wbuiltin-macro-redefined\"")
44
45 #define ARCH_PRAGMA_WRITE_STRINGS \
46 _Pragma("GCC diagnostic ignored \"-Wwrite-strings\"")
47
48 #define ARCH_PRAGMA_UNUSED_FUNCTION \
49 _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
50
51#elif defined(ARCH_COMPILER_CLANG)
52
53 #define ARCH_PRAGMA_PUSH \
54 _Pragma("clang diagnostic push")
55
56 #define ARCH_PRAGMA_POP \
57 _Pragma("clang diagnostic pop")
58
59 #define ARCH_PRAGMA(x) _Pragma(#x)
60
61 #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
62 ARCH_PRAGMA(push_macro(#macro_name))
63
64 #define ARCH_PRAGMA_POP_MACRO(macro_name) \
65 ARCH_PRAGMA(pop_macro(#macro_name))
66
67 #define ARCH_PRAGMA_MACRO_REDEFINITION \
68 _Pragma("clang diagnostic ignored \"-Wbuiltin-macro-redefined\"")
69
70 #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE \
71 _Pragma("clang diagnostic ignored \"-Wundefined-var-template\"")
72
73 #define ARCH_PRAGMA_WRITE_STRINGS \
74 _Pragma("clang diagnostic ignored \"-Wwrite-strings\"")
75
76 #define ARCH_PRAGMA_UNUSED_FUNCTION \
77 _Pragma("clang diagnostic ignored \"-Wunused-function\"")
78
79 #define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD \
80 _Pragma("clang diagnostic ignored \"-Wunused-private-field\"")
81
82 #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION \
83 _Pragma("clang diagnostic ignored \"-Winstantiation-after-specialization\"")
84
85 #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND \
86 _Pragma("clang diagnostic ignored \"-Wobjc-method-access\"")
87
88#elif defined(ARCH_COMPILER_MSVC)
89
90 #define ARCH_PRAGMA_PUSH \
91 __pragma(warning(push))
92
93 #define ARCH_PRAGMA_POP \
94 __pragma(warning(pop))
95
96 #define ARCH_PRAGMA(x) __pragma(x)
97
98 #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
99 __pragma(push_macro(#macro_name))
100
101 #define ARCH_PRAGMA_POP_MACRO(macro_name) \
102 __pragma(pop_macro(#macro_name))
103
104 #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS \
105 __pragma(warning(disable:4003))
106
107 #define ARCH_PRAGMA_MACRO_REDEFINITION \
108 __pragma(warning(disable:4005))
109
110 #define ARCH_PRAGMA_UNUSED_FUNCTION \
111 __pragma(warning(disable:4505))
112
113 #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING \
114 __pragma(warning(disable:4180))
115
116 #define ARCH_PRAGMA_ZERO_SIZED_STRUCT \
117 __pragma(warning(disable:4200))
118
119 #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE \
120 __pragma(warning(disable:4251))
121
122 #define ARCH_PRAGMA_CONVERSION_FROM_SIZET \
123 __pragma(warning(disable:4267))
124
125 #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED \
126 __pragma(warning(disable:4316))
127
128 #define ARCH_PRAGMA_SHIFT_TO_64_BITS \
129 __pragma(warning(disable:4334))
130
131 #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE \
132 __pragma(warning(disable:4624))
133
134 #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME \
135 __pragma(warning(disable:4996))
136
137 #define ARCH_PRAGMA_FORCING_TO_BOOL \
138 __pragma(warning(disable:4800))
139
140 #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL \
141 __pragma(warning(disable:4804))
142
143 #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED \
144 __pragma(warning(disable:4146))
145
146#endif
147
148#if !defined ARCH_PRAGMA_PUSH
149 #define ARCH_PRAGMA_PUSH
150#endif
151
152#if !defined ARCH_PRAGMA_POP
153 #define ARCH_PRAGMA_POP
154#endif
155
156#if !defined ARCH_PRAGMA
157 #define ARCH_PRAGMA
158#endif
159
160#if !defined ARCH_PRAGMA_PUSH_MACRO
161 #define ARCH_PRAGMA_PUSH_MACRO
162#endif
163
164#if !defined ARCH_PRAGMA_POP_MACRO
165 #define ARCH_PRAGMA_POP_MACRO
166#endif
167
168#if !defined ARCH_PRAGMA_MAYBE_UNINITIALIZED
169 #define ARCH_PRAGMA_MAYBE_UNINITIALIZED
170#endif
171
172#if !defined ARCH_PRAGMA_MACRO_REDEFINITION
173 #define ARCH_PRAGMA_MACRO_REDEFINITION
174#endif
175
176#if !defined ARCH_PRAGMA_WRITE_STRINGS
177 #define ARCH_PRAGMA_WRITE_STRINGS
178#endif
179
180#if !defined ARCH_PRAGMA_UNUSED_FUNCTION
181 #define ARCH_PRAGMA_UNUSED_FUNCTION
182#endif
183
184#if !defined ARCH_PRAGMA_UNUSED_PRIVATE_FIELD
185 #define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD
186#endif
187
188#if !defined ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
189 #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
190#endif
191
192#if !defined ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
193 #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
194#endif
195
196#if !defined ARCH_PRAGMA_ZERO_SIZED_STRUCT
197 #define ARCH_PRAGMA_ZERO_SIZED_STRUCT
198#endif
199
200#if !defined ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
201 #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
202#endif
203
204#if !defined ARCH_PRAGMA_CONVERSION_FROM_SIZET
205 #define ARCH_PRAGMA_CONVERSION_FROM_SIZET
206#endif
207
208#if !defined ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
209 #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
210#endif
211
212#if !defined ARCH_PRAGMA_SHIFT_TO_64_BITS
213 #define ARCH_PRAGMA_SHIFT_TO_64_BITS
214#endif
215
216#if !defined ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
217 #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
218#endif
219
220#if !defined ARCH_PRAGMA_DEPRECATED_POSIX_NAME
221 #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME
222#endif
223
224#if !defined ARCH_PRAGMA_FORCING_TO_BOOL
225 #define ARCH_PRAGMA_FORCING_TO_BOOL
226#endif
227
228#if !defined ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
229 #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
230#endif
231
232#if !defined ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
233 #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
234#endif
235
236#if !defined ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
237 #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
238#endif
239
240#if !defined ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
241 #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
242#endif
243
244#if !defined ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
245 #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
246#endif
247
248#endif // PXR_BASE_ARCH_PRAGMAS_H