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_INSTANTIATION_AFTER_SPECIALIZATION \
97  _Pragma("clang diagnostic ignored \"-Winstantiation-after-specialization\"")
98 
99  #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND \
100  _Pragma("clang diagnostic ignored \"-Wobjc-method-access\"")
101 
102 #elif defined(ARCH_COMPILER_MSVC)
103 
104  #define ARCH_PRAGMA_PUSH \
105  __pragma(warning(push))
106 
107  #define ARCH_PRAGMA_POP \
108  __pragma(warning(pop))
109 
110  #define ARCH_PRAGMA(x) __pragma(x)
111 
112  #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
113  __pragma(push_macro(#macro_name))
114 
115  #define ARCH_PRAGMA_POP_MACRO(macro_name) \
116  __pragma(pop_macro(#macro_name))
117 
118  #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS \
119  __pragma(warning(disable:4003))
120 
121  #define ARCH_PRAGMA_MACRO_REDEFINITION \
122  __pragma(warning(disable:4005))
123 
124  #define ARCH_PRAGMA_UNUSED_FUNCTION \
125  __pragma(warning(disable:4505))
126 
127  #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING \
128  __pragma(warning(disable:4180))
129 
130  #define ARCH_PRAGMA_ZERO_SIZED_STRUCT \
131  __pragma(warning(disable:4200))
132 
133  #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE \
134  __pragma(warning(disable:4251))
135 
136  #define ARCH_PRAGMA_CONVERSION_FROM_SIZET \
137  __pragma(warning(disable:4267))
138 
139  #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED \
140  __pragma(warning(disable:4316))
141 
142  #define ARCH_PRAGMA_SHIFT_TO_64_BITS \
143  __pragma(warning(disable:4334))
144 
145  #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE \
146  __pragma(warning(disable:4624))
147 
148  #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME \
149  __pragma(warning(disable:4996))
150 
151  #define ARCH_PRAGMA_FORCING_TO_BOOL \
152  __pragma(warning(disable:4800))
153 
154  #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL \
155  __pragma(warning(disable:4804))
156 
157  #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED \
158  __pragma(warning(disable:4146))
159 
160 #endif
161 
162 #if !defined ARCH_PRAGMA_PUSH
163  #define ARCH_PRAGMA_PUSH
164 #endif
165 
166 #if !defined ARCH_PRAGMA_POP
167  #define ARCH_PRAGMA_POP
168 #endif
169 
170 #if !defined ARCH_PRAGMA
171  #define ARCH_PRAGMA
172 #endif
173 
174 #if !defined ARCH_PRAGMA_PUSH_MACRO
175  #define ARCH_PRAGMA_PUSH_MACRO
176 #endif
177 
178 #if !defined ARCH_PRAGMA_POP_MACRO
179  #define ARCH_PRAGMA_POP_MACRO
180 #endif
181 
182 #if !defined ARCH_PRAGMA_MAYBE_UNINITIALIZED
183  #define ARCH_PRAGMA_MAYBE_UNINITIALIZED
184 #endif
185 
186 #if !defined ARCH_PRAGMA_MACRO_REDEFINITION
187  #define ARCH_PRAGMA_MACRO_REDEFINITION
188 #endif
189 
190 #if !defined ARCH_PRAGMA_WRITE_STRINGS
191  #define ARCH_PRAGMA_WRITE_STRINGS
192 #endif
193 
194 #if !defined ARCH_PRAGMA_UNUSED_FUNCTION
195  #define ARCH_PRAGMA_UNUSED_FUNCTION
196 #endif
197 
198 #if !defined ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
199  #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
200 #endif
201 
202 #if !defined ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
203  #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
204 #endif
205 
206 #if !defined ARCH_PRAGMA_ZERO_SIZED_STRUCT
207  #define ARCH_PRAGMA_ZERO_SIZED_STRUCT
208 #endif
209 
210 #if !defined ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
211  #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
212 #endif
213 
214 #if !defined ARCH_PRAGMA_CONVERSION_FROM_SIZET
215  #define ARCH_PRAGMA_CONVERSION_FROM_SIZET
216 #endif
217 
218 #if !defined ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
219  #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
220 #endif
221 
222 #if !defined ARCH_PRAGMA_SHIFT_TO_64_BITS
223  #define ARCH_PRAGMA_SHIFT_TO_64_BITS
224 #endif
225 
226 #if !defined ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
227  #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
228 #endif
229 
230 #if !defined ARCH_PRAGMA_DEPRECATED_POSIX_NAME
231  #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME
232 #endif
233 
234 #if !defined ARCH_PRAGMA_FORCING_TO_BOOL
235  #define ARCH_PRAGMA_FORCING_TO_BOOL
236 #endif
237 
238 #if !defined ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
239  #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
240 #endif
241 
242 #if !defined ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
243  #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
244 #endif
245 
246 #if !defined ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
247  #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
248 #endif
249 
250 #if !defined ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
251  #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
252 #endif
253 
254 #if !defined ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
255  #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
256 #endif
257 
258 #endif // PXR_BASE_ARCH_PRAGMAS_H