HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pragmas.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_BASE_ARCH_PRAGMAS_H
25 #define PXR_BASE_ARCH_PRAGMAS_H
26 
27 /// \file arch/pragmas.h
28 /// Pragmas for controlling compiler-specific behaviors.
29 ///
30 /// This header contains pragmas used to control compiler-specific behaviors.
31 /// Behaviors that are not supported or required by a certain compiler should
32 /// be implemented as a no-op.
33 
34 #include "pxr/base/arch/defines.h"
35 
36 #if defined(ARCH_COMPILER_GCC)
37 
38  #define ARCH_PRAGMA_PUSH \
39  _Pragma("GCC diagnostic push")
40 
41  #define ARCH_PRAGMA_POP \
42  _Pragma("GCC diagnostic pop")
43 
44  #define ARCH_PRAGMA(x) _Pragma(#x)
45 
46  #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
47  ARCH_PRAGMA(push_macro(#macro_name))
48 
49  #define ARCH_PRAGMA_POP_MACRO(macro_name) \
50  ARCH_PRAGMA(pop_macro(#macro_name))
51 
52  // Convert errors about variables that may be used before initialization
53  // into warnings.
54  //
55  // This works around GCC bug 47679.
56  #define ARCH_PRAGMA_MAYBE_UNINITIALIZED \
57  _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
58 
59  #define ARCH_PRAGMA_MACRO_REDEFINITION \
60  _Pragma("GCC diagnostic ignored \"-Wbuiltin-macro-redefined\"")
61 
62  #define ARCH_PRAGMA_WRITE_STRINGS \
63  _Pragma("GCC diagnostic ignored \"-Wwrite-strings\"")
64 
65  #define ARCH_PRAGMA_UNUSED_FUNCTION \
66  _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
67 
68 #elif defined(ARCH_COMPILER_CLANG)
69 
70  #define ARCH_PRAGMA_PUSH \
71  _Pragma("clang diagnostic push")
72 
73  #define ARCH_PRAGMA_POP \
74  _Pragma("clang diagnostic pop")
75 
76  #define ARCH_PRAGMA(x) _Pragma(#x)
77 
78  #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
79  ARCH_PRAGMA(push_macro(#macro_name))
80 
81  #define ARCH_PRAGMA_POP_MACRO(macro_name) \
82  ARCH_PRAGMA(pop_macro(#macro_name))
83 
84  #define ARCH_PRAGMA_MACRO_REDEFINITION \
85  _Pragma("clang diagnostic ignored \"-Wbuiltin-macro-redefined\"")
86 
87  #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE \
88  _Pragma("clang diagnostic ignored \"-Wundefined-var-template\"")
89 
90  #define ARCH_PRAGMA_WRITE_STRINGS \
91  _Pragma("clang diagnostic ignored \"-Wwrite-strings\"")
92 
93  #define ARCH_PRAGMA_UNUSED_FUNCTION \
94  _Pragma("clang diagnostic ignored \"-Wunused-function\"")
95 
96  #define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD \
97  _Pragma("clang diagnostic ignored \"-Wunused-private-field\"")
98 
99  #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION \
100  _Pragma("clang diagnostic ignored \"-Winstantiation-after-specialization\"")
101 
102  #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND \
103  _Pragma("clang diagnostic ignored \"-Wobjc-method-access\"")
104 
105 #elif defined(ARCH_COMPILER_MSVC)
106 
107  #define ARCH_PRAGMA_PUSH \
108  __pragma(warning(push))
109 
110  #define ARCH_PRAGMA_POP \
111  __pragma(warning(pop))
112 
113  #define ARCH_PRAGMA(x) __pragma(x)
114 
115  #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
116  __pragma(push_macro(#macro_name))
117 
118  #define ARCH_PRAGMA_POP_MACRO(macro_name) \
119  __pragma(pop_macro(#macro_name))
120 
121  #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS \
122  __pragma(warning(disable:4003))
123 
124  #define ARCH_PRAGMA_MACRO_REDEFINITION \
125  __pragma(warning(disable:4005))
126 
127  #define ARCH_PRAGMA_UNUSED_FUNCTION \
128  __pragma(warning(disable:4505))
129 
130  #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING \
131  __pragma(warning(disable:4180))
132 
133  #define ARCH_PRAGMA_ZERO_SIZED_STRUCT \
134  __pragma(warning(disable:4200))
135 
136  #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE \
137  __pragma(warning(disable:4251))
138 
139  #define ARCH_PRAGMA_CONVERSION_FROM_SIZET \
140  __pragma(warning(disable:4267))
141 
142  #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED \
143  __pragma(warning(disable:4316))
144 
145  #define ARCH_PRAGMA_SHIFT_TO_64_BITS \
146  __pragma(warning(disable:4334))
147 
148  #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE \
149  __pragma(warning(disable:4624))
150 
151  #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME \
152  __pragma(warning(disable:4996))
153 
154  #define ARCH_PRAGMA_FORCING_TO_BOOL \
155  __pragma(warning(disable:4800))
156 
157  #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL \
158  __pragma(warning(disable:4804))
159 
160  #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED \
161  __pragma(warning(disable:4146))
162 
163 #endif
164 
165 #if !defined ARCH_PRAGMA_PUSH
166  #define ARCH_PRAGMA_PUSH
167 #endif
168 
169 #if !defined ARCH_PRAGMA_POP
170  #define ARCH_PRAGMA_POP
171 #endif
172 
173 #if !defined ARCH_PRAGMA
174  #define ARCH_PRAGMA
175 #endif
176 
177 #if !defined ARCH_PRAGMA_PUSH_MACRO
178  #define ARCH_PRAGMA_PUSH_MACRO
179 #endif
180 
181 #if !defined ARCH_PRAGMA_POP_MACRO
182  #define ARCH_PRAGMA_POP_MACRO
183 #endif
184 
185 #if !defined ARCH_PRAGMA_MAYBE_UNINITIALIZED
186  #define ARCH_PRAGMA_MAYBE_UNINITIALIZED
187 #endif
188 
189 #if !defined ARCH_PRAGMA_MACRO_REDEFINITION
190  #define ARCH_PRAGMA_MACRO_REDEFINITION
191 #endif
192 
193 #if !defined ARCH_PRAGMA_WRITE_STRINGS
194  #define ARCH_PRAGMA_WRITE_STRINGS
195 #endif
196 
197 #if !defined ARCH_PRAGMA_UNUSED_FUNCTION
198  #define ARCH_PRAGMA_UNUSED_FUNCTION
199 #endif
200 
201 #if !defined ARCH_PRAGMA_UNUSED_PRIVATE_FIELD
202  #define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD
203 #endif
204 
205 #if !defined ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
206  #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
207 #endif
208 
209 #if !defined ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
210  #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
211 #endif
212 
213 #if !defined ARCH_PRAGMA_ZERO_SIZED_STRUCT
214  #define ARCH_PRAGMA_ZERO_SIZED_STRUCT
215 #endif
216 
217 #if !defined ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
218  #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
219 #endif
220 
221 #if !defined ARCH_PRAGMA_CONVERSION_FROM_SIZET
222  #define ARCH_PRAGMA_CONVERSION_FROM_SIZET
223 #endif
224 
225 #if !defined ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
226  #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
227 #endif
228 
229 #if !defined ARCH_PRAGMA_SHIFT_TO_64_BITS
230  #define ARCH_PRAGMA_SHIFT_TO_64_BITS
231 #endif
232 
233 #if !defined ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
234  #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
235 #endif
236 
237 #if !defined ARCH_PRAGMA_DEPRECATED_POSIX_NAME
238  #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME
239 #endif
240 
241 #if !defined ARCH_PRAGMA_FORCING_TO_BOOL
242  #define ARCH_PRAGMA_FORCING_TO_BOOL
243 #endif
244 
245 #if !defined ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
246  #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
247 #endif
248 
249 #if !defined ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
250  #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
251 #endif
252 
253 #if !defined ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
254  #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
255 #endif
256 
257 #if !defined ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
258  #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
259 #endif
260 
261 #if !defined ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
262  #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
263 #endif
264 
265 #endif // PXR_BASE_ARCH_PRAGMAS_H