This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pragmas.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_BASE_ARCH_PRAGMAS_H
8#define PXR_BASE_ARCH_PRAGMAS_H
9
16
17#include "pxr/base/arch/defines.h"
18
19#if defined(ARCH_COMPILER_GCC)
20
21 #define ARCH_PRAGMA_PUSH \
22 _Pragma("GCC diagnostic push")
23
24 #define ARCH_PRAGMA_POP \
25 _Pragma("GCC diagnostic pop")
26
27 #define ARCH_PRAGMA(x) _Pragma(#x)
28
29 #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
30 ARCH_PRAGMA(push_macro(#macro_name))
31
32 #define ARCH_PRAGMA_POP_MACRO(macro_name) \
33 ARCH_PRAGMA(pop_macro(#macro_name))
34
35 // Convert errors about variables that may be used before initialization
36 // into warnings.
37 //
38 // This works around GCC bug 47679.
39 #define ARCH_PRAGMA_MAYBE_UNINITIALIZED \
40 _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
41
42 #define ARCH_PRAGMA_MACRO_REDEFINITION \
43 _Pragma("GCC diagnostic ignored \"-Wbuiltin-macro-redefined\"")
44
45 #define ARCH_PRAGMA_WRITE_STRINGS \
46 _Pragma("GCC diagnostic ignored \"-Wwrite-strings\"")
47
48 #define ARCH_PRAGMA_UNUSED_FUNCTION \
49 _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
50
51 #define ARCH_PRAGMA_STRINGOP_OVERFLOW \
52 _Pragma("GCC diagnostic ignored \"-Wstringop-overflow=\"")
53
54#elif defined(ARCH_COMPILER_CLANG)
55
56 #define ARCH_PRAGMA_PUSH \
57 _Pragma("clang diagnostic push")
58
59 #define ARCH_PRAGMA_POP \
60 _Pragma("clang diagnostic pop")
61
62 #define ARCH_PRAGMA(x) _Pragma(#x)
63
64 #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
65 ARCH_PRAGMA(push_macro(#macro_name))
66
67 #define ARCH_PRAGMA_POP_MACRO(macro_name) \
68 ARCH_PRAGMA(pop_macro(#macro_name))
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_UNUSED_FUNCTION \
80 _Pragma("clang diagnostic ignored \"-Wunused-function\"")
81
82 #define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD \
83 _Pragma("clang diagnostic ignored \"-Wunused-private-field\"")
84
85 #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION \
86 _Pragma("clang diagnostic ignored \"-Winstantiation-after-specialization\"")
87
88 #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND \
89 _Pragma("clang diagnostic ignored \"-Wobjc-method-access\"")
90
91#elif defined(ARCH_COMPILER_MSVC)
92
93 #define ARCH_PRAGMA_PUSH \
94 __pragma(warning(push))
95
96 #define ARCH_PRAGMA_POP \
97 __pragma(warning(pop))
98
99 #define ARCH_PRAGMA(x) __pragma(x)
100
101 #define ARCH_PRAGMA_PUSH_MACRO(macro_name) \
102 __pragma(push_macro(#macro_name))
103
104 #define ARCH_PRAGMA_POP_MACRO(macro_name) \
105 __pragma(pop_macro(#macro_name))
106
107 #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS \
108 __pragma(warning(disable:4003))
109
110 #define ARCH_PRAGMA_MACRO_REDEFINITION \
111 __pragma(warning(disable:4005))
112
113 #define ARCH_PRAGMA_UNUSED_FUNCTION \
114 __pragma(warning(disable:4505))
115
116 #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING \
117 __pragma(warning(disable:4180))
118
119 #define ARCH_PRAGMA_ZERO_SIZED_STRUCT \
120 __pragma(warning(disable:4200))
121
122 #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE \
123 __pragma(warning(disable:4251))
124
125 #define ARCH_PRAGMA_CONVERSION_FROM_SIZET \
126 __pragma(warning(disable:4267))
127
128 #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED \
129 __pragma(warning(disable:4316))
130
131 #define ARCH_PRAGMA_SHIFT_TO_64_BITS \
132 __pragma(warning(disable:4334))
133
134 #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE \
135 __pragma(warning(disable:4624))
136
137 #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME \
138 __pragma(warning(disable:4996))
139
140 #define ARCH_PRAGMA_FORCING_TO_BOOL \
141 __pragma(warning(disable:4800))
142
143 #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL \
144 __pragma(warning(disable:4804))
145
146 #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED \
147 __pragma(warning(disable:4146))
148
149#endif
150
151#if !defined ARCH_PRAGMA_PUSH
152 #define ARCH_PRAGMA_PUSH
153#endif
154
155#if !defined ARCH_PRAGMA_POP
156 #define ARCH_PRAGMA_POP
157#endif
158
159#if !defined ARCH_PRAGMA
160 #define ARCH_PRAGMA
161#endif
162
163#if !defined ARCH_PRAGMA_PUSH_MACRO
164 #define ARCH_PRAGMA_PUSH_MACRO
165#endif
166
167#if !defined ARCH_PRAGMA_POP_MACRO
168 #define ARCH_PRAGMA_POP_MACRO
169#endif
170
171#if !defined ARCH_PRAGMA_MAYBE_UNINITIALIZED
172 #define ARCH_PRAGMA_MAYBE_UNINITIALIZED
173#endif
174
175#if !defined ARCH_PRAGMA_MACRO_REDEFINITION
176 #define ARCH_PRAGMA_MACRO_REDEFINITION
177#endif
178
179#if !defined ARCH_PRAGMA_WRITE_STRINGS
180 #define ARCH_PRAGMA_WRITE_STRINGS
181#endif
182
183#if !defined ARCH_PRAGMA_UNUSED_FUNCTION
184 #define ARCH_PRAGMA_UNUSED_FUNCTION
185#endif
186
187#if !defined ARCH_PRAGMA_STRINGOP_OVERFLOW
188 #define ARCH_PRAGMA_STRINGOP_OVERFLOW
189#endif
190
191#if !defined ARCH_PRAGMA_UNUSED_PRIVATE_FIELD
192 #define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD
193#endif
194
195#if !defined ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
196 #define ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
197#endif
198
199#if !defined ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
200 #define ARCH_PRAGMA_QUALIFIER_HAS_NO_MEANING
201#endif
202
203#if !defined ARCH_PRAGMA_ZERO_SIZED_STRUCT
204 #define ARCH_PRAGMA_ZERO_SIZED_STRUCT
205#endif
206
207#if !defined ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
208 #define ARCH_PRAGMA_NEEDS_EXPORT_INTERFACE
209#endif
210
211#if !defined ARCH_PRAGMA_CONVERSION_FROM_SIZET
212 #define ARCH_PRAGMA_CONVERSION_FROM_SIZET
213#endif
214
215#if !defined ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
216 #define ARCH_PRAGMA_MAY_NOT_BE_ALIGNED
217#endif
218
219#if !defined ARCH_PRAGMA_SHIFT_TO_64_BITS
220 #define ARCH_PRAGMA_SHIFT_TO_64_BITS
221#endif
222
223#if !defined ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
224 #define ARCH_PRAGMA_DESTRUCTOR_IMPLICIT_DEFINE
225#endif
226
227#if !defined ARCH_PRAGMA_DEPRECATED_POSIX_NAME
228 #define ARCH_PRAGMA_DEPRECATED_POSIX_NAME
229#endif
230
231#if !defined ARCH_PRAGMA_FORCING_TO_BOOL
232 #define ARCH_PRAGMA_FORCING_TO_BOOL
233#endif
234
235#if !defined ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
236 #define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
237#endif
238
239#if !defined ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
240 #define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
241#endif
242
243#if !defined ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
244 #define ARCH_PRAGMA_INSTANTIATION_AFTER_SPECIALIZATION
245#endif
246
247#if !defined ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
248 #define ARCH_PRAGMA_UNDEFINED_VAR_TEMPLATE
249#endif
250
251#if !defined ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
252 #define ARCH_PRAGMA_INSTANCE_METHOD_NOT_FOUND
253#endif
254
255#endif // PXR_BASE_ARCH_PRAGMAS_H