OpenVDB 7.0.0

Platform.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
5
6 #ifndef OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
7 #define OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
8
9 #include "PlatformConfig.h"
10
11 #define PRAGMA(x) _Pragma(#x)
12
16 #define OPENVDB_PREPROC_STRINGIFY_(x) #x
17 #define OPENVDB_PREPROC_STRINGIFY(x) OPENVDB_PREPROC_STRINGIFY_(x)
22
24 #define OPENVDB_PREPROC_CONCAT_(x, y) x ## y
25 #define OPENVDB_PREPROC_CONCAT(x, y) OPENVDB_PREPROC_CONCAT_(x, y)
30
32
36 #ifdef OPENVDB_DEPRECATED
37 #undef OPENVDB_DEPRECATED
38 #endif
39 #ifdef _MSC_VER
40 #define OPENVDB_DEPRECATED __declspec(deprecated)
41 #else
42 #define OPENVDB_DEPRECATED __attribute__ ((deprecated))
43 #endif
44
46 #if defined(__GNUC__)
47 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) \
48 (__GNUC__ > MAJOR || (__GNUC__ == MAJOR && __GNUC_MINOR__ >= MINOR))
49 #else
50 #define OPENVDB_CHECK_GCC(MAJOR, MINOR) 0
51 #endif
52
54 #define OPENVDB_HAS_CXX11 1
55
59 #if defined(__GNUC__) && OPENVDB_CHECK_GCC(4, 4)
60 #define OPENVDB_STATIC_SPECIALIZATION
61 #else
62 #define OPENVDB_STATIC_SPECIALIZATION static
63 #endif
64
65
67 #if defined(OPENVDB_USE_SSE42) || defined(OPENVDB_USE_AVX)
68 #if defined(_WIN32)
69 #include <intrin.h>
70 #elif defined(__GNUC__)
71 #if defined(__x86_64__) || defined(__i386__)
72 #include <x86intrin.h>
73 #elif defined(__ARM_NEON__)
74 #include <arm_neon.h>
75 #endif
76 #endif
77 #endif
78
79
95 #if defined(__INTEL_COMPILER)
96 // Disable ICC remarks 111 ("statement is unreachable"), 128 ("loop is not reachable"),
97 // 185 ("dynamic initialization in unreachable code"), and 280 ("selector expression
98 // is constant").
99 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
100 _Pragma("warning (push)") \
101 _Pragma("warning (disable:111)") \
102 _Pragma("warning (disable:128)") \
103 _Pragma("warning (disable:185)") \
104 _Pragma("warning (disable:280)")
105 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
106 _Pragma("warning (pop)")
107 #elif defined(__clang__)
108 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN \
109 PRAGMA(clang diagnostic push) \
110 PRAGMA(clang diagnostic ignored "-Wunreachable-code")
111 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END \
112 PRAGMA(clang diagnostic pop)
113 #else
114 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
115 #define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
116 #endif
117
118
132 #if defined __INTEL_COMPILER
133 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
134 _Pragma("warning (push)") \
135 _Pragma("warning (disable:1478)") \
136 PRAGMA(message("NOTE: ignoring deprecation warning at " __FILE__ \
137 ":" OPENVDB_PREPROC_STRINGIFY(__LINE__)))
138 #define OPENVDB_NO_DEPRECATION_WARNING_END \
139 _Pragma("warning (pop)")
140 #elif defined __clang__
141 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
142 _Pragma("clang diagnostic push") \
143 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
144 // note: no #pragma message, since Clang treats them as warnings
145 #define OPENVDB_NO_DEPRECATION_WARNING_END \
146 _Pragma("clang diagnostic pop")
147 #elif defined __GNUC__
148 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
149 _Pragma("GCC diagnostic push") \
150 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
151 _Pragma("message(\"NOTE: ignoring deprecation warning\")")
152 #define OPENVDB_NO_DEPRECATION_WARNING_END \
153 _Pragma("GCC diagnostic pop")
154 #elif defined _MSC_VER
155 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN \
156 __pragma(warning(push)) \
157 __pragma(warning(disable : 4996)) \
158 __pragma(message("NOTE: ignoring deprecation warning at " __FILE__ \
159 ":" OPENVDB_PREPROC_STRINGIFY(__LINE__)))
160 #define OPENVDB_NO_DEPRECATION_WARNING_END \
161 __pragma(warning(pop))
162 #else
163 #define OPENVDB_NO_DEPRECATION_WARNING_BEGIN
164 #define OPENVDB_NO_DEPRECATION_WARNING_END
165 #endif
166
167
178 #if defined __INTEL_COMPILER
179 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
180 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
181 #elif defined __GNUC__
182 // -Wfloat-conversion was only introduced in GCC 4.9
183 #if OPENVDB_CHECK_GCC(4, 9)
184 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \
185 _Pragma("GCC diagnostic push") \
186 _Pragma("GCC diagnostic ignored \"-Wconversion\"") \
187 _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"")
188 #else
189 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \
190 _Pragma("GCC diagnostic push") \
191 _Pragma("GCC diagnostic ignored \"-Wconversion\"")
192 #endif
193 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END \
194 _Pragma("GCC diagnostic pop")
195 #else
196 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
197 #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
198 #endif
199
201 #ifdef OPENVDB_EXPORT
202 #undef OPENVDB_EXPORT
203 #endif
204 #ifdef OPENVDB_IMPORT
205 #undef OPENVDB_IMPORT
206 #endif
207 #ifdef __GNUC__
208 #define OPENVDB_EXPORT __attribute__((visibility("default")))
209 #define OPENVDB_IMPORT __attribute__((visibility("default")))
210 #endif
211 #ifdef _WIN32
212 #ifdef OPENVDB_DLL
213 #define OPENVDB_EXPORT __declspec(dllexport)
214 #define OPENVDB_IMPORT __declspec(dllimport)
215 #else
216 #define OPENVDB_EXPORT
217 #define OPENVDB_IMPORT
218 #endif
219 #endif
220
224 #ifdef OPENVDB_API
225 #undef OPENVDB_API
226 #endif
227 #ifdef OPENVDB_PRIVATE
228 #define OPENVDB_API OPENVDB_EXPORT
229 #else
230 #define OPENVDB_API OPENVDB_IMPORT
231 #endif
232 #ifdef OPENVDB_HOUDINI_API
233 #undef OPENVDB_HOUDINI_API
234 #endif
235 #ifdef OPENVDB_HOUDINI_PRIVATE
236 #define OPENVDB_HOUDINI_API OPENVDB_EXPORT
237 #else
238 #define OPENVDB_HOUDINI_API OPENVDB_IMPORT
239 #endif
240
241 #endif // OPENVDB_PLATFORM_HAS_BEEN_INCLUDED
PlatformConfig.h