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