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