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  // Convert errors about variables that may be used before initialization
45  // into warnings.
46  //
47  // This works around GCC bug 47679.
48  #define ARCH_PRAGMA_MAYBE_UNINITIALIZED \
49  _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
50 
51  #define ARCH_PRAGMA_MACRO_REDEFINITION \
52  _Pragma("GCC diagnostic ignored \"-Wbuiltin-macro-redefined\"")
53 
54  #define ARCH_PRAGMA_WRITE_STRINGS \
55  _Pragma("GCC diagnostic ignored \"-Wwrite-strings\"")
56 
57  #define ARCH_PRAGMA_UNUSED_FUNCTION \
58  _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
59 
60 #elif defined(ARCH_COMPILER_CLANG)
61 
62  #define ARCH_PRAGMA_PUSH \
63  _Pragma("clang diagnostic push")
64 
65  #define ARCH_PRAGMA_POP \
66  _Pragma("clang diagnostic pop")
67 
68  #define ARCH_PRAGMA_MACRO_REDEFINITION \
69  _Pragma("clang diagnostic ignored \"-Wbuiltin-macro-redefined\"")
70 
71  #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE \
72  _Pragma("clang diagnostic ignored \"-Wundefined-var-template\"")
73 
74  #define ARCH_PRAGMA_WRITE_STRINGS \
75  _Pragma("clang diagnostic ignored \"-Wwrite-strings\"")
76 
77  #define ARCH_PRAGMA_UNUSED_FUNCTION \
78  _Pragma("clang diagnostic ignored \"-Wunused-function\"")
79 
80  #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION \
81  _Pragma("clang diagnostic ignored \"-Winstantiation-after-specialization\"")
82 
83  #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND \
84  _Pragma("clang diagnostic ignored \"-Wobjc-method-access\"")
85 
86 #elif defined(ARCH_COMPILER_MSVC)
87 
88  #define ARCH_PRAGMA_PUSH \
89  __pragma(warning(push))
90 
91  #define ARCH_PRAGMA_POP \
92  __pragma(warning(pop))
93 
94  #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS \
95  __pragma(warning(disable:4003))
96 
97  #define ARCH_PRAGMA_MACRO_REDEFINITION \
98  __pragma(warning(disable:4005))
99 
100  #define ARCH_PRAGMA_UNUSED_FUNCTION \
101  __pragma(warning(disable:4505))
102 
103  #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING \
104  __pragma(warning(disable:4180))
105 
106  #define ARCH_PRAGMA_ZERO_SIZED_STRUCT \
107  __pragma(warning(disable:4200))
108 
109  #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE \
110  __pragma(warning(disable:4251))
111 
112  #define ARCH_PRAGMA_CONVERSION_FROM_SIZET \
113  __pragma(warning(disable:4267))
114 
115  #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED \
116  __pragma(warning(disable:4316))
117 
118  #define ARCH_PRAGMA_SHIFT_TO_64_BITS \
119  __pragma(warning(disable:4334))
120 
121  #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE \
122  __pragma(warning(disable:4624))
123 
124  #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME \
125  __pragma(warning(disable:4996))
126 
127  #define ARCH_PRAGMA_FORCING_TO_BOOL \
128  __pragma(warning(disable:4800))
129 
130  #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL \
131  __pragma(warning(disable:4804))
132 
133  #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED \
134  __pragma(warning(disable:4146))
135 
136 #endif
137 
138 #if !defined ARCH_PRAGMA_PUSH
139  #define ARCH_PRAGMA_PUSH
140 #endif
141 
142 #if !defined ARCH_PRAGMA_POP
143  #define ARCH_PRAGMA_POP
144 #endif
145 
146 #if !defined ARCH_PRAGMA_MAYBE_UNINITIALIZED
147  #define ARCH_PRAGMA_MAYBE_UNINITIALIZED
148 #endif
149 
150 #if !defined ARCH_PRAGMA_MACRO_REDEFINITION
151  #define ARCH_PRAGMA_MACRO_REDEFINITION
152 #endif
153 
154 #if !defined ARCH_PRAGMA_WRITE_STRINGS
155  #define ARCH_PRAGMA_WRITE_STRINGS
156 #endif
157 
158 #if !defined ARCH_PRAGMA_UNUSED_FUNCTION
159  #define ARCH_PRAGMA_UNUSED_FUNCTION
160 #endif
161 
162 #if !defined ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
163  #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
164 #endif
165 
166 #if !defined ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
167  #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
168 #endif
169 
170 #if !defined ARCH_PRAGMA_ZERO_SIZED_STRUCT
171  #define ARCH_PRAGMA_ZERO_SIZED_STRUCT
172 #endif
173 
174 #if !defined ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
175  #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
176 #endif
177 
178 #if !defined ARCH_PRAGMA_CONVERSION_FROM_SIZET
179  #define ARCH_PRAGMA_CONVERSION_FROM_SIZET
180 #endif
181 
182 #if !defined ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
183  #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
184 #endif
185 
186 #if !defined ARCH_PRAGMA_SHIFT_TO_64_BITS
187  #define ARCH_PRAGMA_SHIFT_TO_64_BITS
188 #endif
189 
190 #if !defined ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
191  #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
192 #endif
193 
194 #if !defined ARCH_PRAGMA_DEPRECATED_POSIX_NAME
195  #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME
196 #endif
197 
198 #if !defined ARCH_PRAGMA_FORCING_TO_BOOL
199  #define ARCH_PRAGMA_FORCING_TO_BOOL
200 #endif
201 
202 #if !defined ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
203  #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
204 #endif
205 
206 #if !defined ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
207  #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
208 #endif
209 
210 #if !defined ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
211  #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
212 #endif
213 
214 #if !defined ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
215  #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
216 #endif
217 
218 #if !defined ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
219  #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
220 #endif
221 
222 #endif // PXR_BASE_ARCH_PRAGMAS_H