0.9.9 API documenation: setup.hpp Source File

| 0.9.9 API documenation

- Main Page
- Modules
- Files

- File List

setup.hpp
Go to the documentation of this file.
1
4 #ifndef GLM_SETUP_INCLUDED
5
6 #define GLM_VERSION_MAJOR 0
7 #define GLM_VERSION_MINOR 9
8 #define GLM_VERSION_PATCH 9
9 #define GLM_VERSION_REVISION 0
10 #define GLM_VERSION 990
11
12 #define GLM_SETUP_INCLUDED GLM_VERSION
13
14 #if defined(GLM_FORCE_SWIZZLE) && defined(GLM_FORCE_UNRESTRICTED_GENTYPE)
15 # error "Both GLM_FORCE_SWIZZLE and GLM_FORCE_UNRESTRICTED_GENTYPE can't be defined at the same time"
16 #endif
17
18 #include <cassert>
19 #include <cstddef>
20
22 // Messages
23
24 #define GLM_MESSAGES_ENABLED 1
25 #define GLM_MESSAGES_DISABLE 0
26
27 #if defined(GLM_FORCE_MESSAGES)
28 # define GLM_MESSAGES GLM_MESSAGES_ENABLED
29 #else
30 # define GLM_MESSAGES GLM_MESSAGES_DISABLE
31 #endif
32
34 // Detect the platform
35
36 #include "../simd/platform.h"
37
39 // Version
40
41 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_VERSION_DISPLAYED)
42 # define GLM_MESSAGE_VERSION_DISPLAYED
43 # pragma message ("GLM: version 0.9.9.0")
44 #endif//GLM_MESSAGES
45
46 // Report compiler detection
47 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_COMPILER_DISPLAYED)
48 # define GLM_MESSAGE_COMPILER_DISPLAYED
49 # if GLM_COMPILER & GLM_COMPILER_CUDA
50 # pragma message("GLM: CUDA compiler detected")
51 # elif GLM_COMPILER & GLM_COMPILER_VC
52 # pragma message("GLM: Visual C++ compiler detected")
53 # elif GLM_COMPILER & GLM_COMPILER_CLANG
54 # pragma message("GLM: Clang compiler detected")
55 # elif GLM_COMPILER & GLM_COMPILER_INTEL
56 # pragma message("GLM: Intel Compiler detected")
57 # elif GLM_COMPILER & GLM_COMPILER_GCC
58 # pragma message("GLM: GCC compiler detected")
59 # else
60 # pragma message("GLM: Compiler not detected")
61 # endif
62 #endif//GLM_MESSAGES
63
65 // Build model
66
67 #if defined(__arch64__) || defined(__LP64__) || defined(_M_X64) || defined(__ppc64__) || defined(__x86_64__)
68 # define GLM_MODEL GLM_MODEL_64
69 #elif defined(__i386__) || defined(__ppc__)
70 # define GLM_MODEL GLM_MODEL_32
71 #else
72 # define GLM_MODEL GLM_MODEL_32
73 #endif//
74
75 #if !defined(GLM_MODEL) && GLM_COMPILER != 0
76 # error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
77 #endif//GLM_MODEL
78
79 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_MODEL_DISPLAYED)
80 # define GLM_MESSAGE_MODEL_DISPLAYED
81 # if(GLM_MODEL == GLM_MODEL_64)
82 # pragma message("GLM: 64 bits model")
83 # elif(GLM_MODEL == GLM_MODEL_32)
84 # pragma message("GLM: 32 bits model")
85 # endif//GLM_MODEL
86 #endif//GLM_MESSAGES
87
88 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_ARCH_DISPLAYED)
89 # define GLM_MESSAGE_ARCH_DISPLAYED
90 # if(GLM_ARCH == GLM_ARCH_PURE)
91 # pragma message("GLM: Platform independent code")
92 # elif(GLM_ARCH == GLM_ARCH_AVX2)
93 # pragma message("GLM: AVX2 instruction set")
94 # elif(GLM_ARCH == GLM_ARCH_AVX)
95 # pragma message("GLM: AVX instruction set")
96 # elif(GLM_ARCH == GLM_ARCH_SSE42)
97 # pragma message("GLM: SSE4.2 instruction set")
98 # elif(GLM_ARCH == GLM_ARCH_SSE41)
99 # pragma message("GLM: SSE4.1 instruction set")
100 # elif(GLM_ARCH == GLM_ARCH_SSSE3)
101 # pragma message("GLM: SSSE3 instruction set")
102 # elif(GLM_ARCH == GLM_ARCH_SSE3)
103 # pragma message("GLM: SSE3 instruction set")
104 # elif(GLM_ARCH == GLM_ARCH_SSE2)
105 # pragma message("GLM: SSE2 instruction set")
106 # elif(GLM_ARCH == GLM_ARCH_X86)
107 # pragma message("GLM: x86 instruction set")
108 # elif(GLM_ARCH == GLM_ARCH_NEON)
109 # pragma message("GLM: NEON instruction set")
110 # elif(GLM_ARCH == GLM_ARCH_ARM)
111 # pragma message("GLM: ARM instruction set")
112 # elif(GLM_ARCH == GLM_ARCH_MIPS)
113 # pragma message("GLM: MIPS instruction set")
114 # elif(GLM_ARCH == GLM_ARCH_PPC)
115 # pragma message("GLM: PowerPC architechture")
116 # endif//GLM_ARCH
117 #endif//GLM_MESSAGES
118
120 // C++ Version
121
122 // User defines: GLM_FORCE_CXX98, GLM_FORCE_CXX03, GLM_FORCE_CXX11, GLM_FORCE_CXX14
123
124 #define GLM_LANG_CXX98_FLAG (1 << 1)
125 #define GLM_LANG_CXX03_FLAG (1 << 2)
126 #define GLM_LANG_CXX0X_FLAG (1 << 3)
127 #define GLM_LANG_CXX11_FLAG (1 << 4)
128 #define GLM_LANG_CXX1Y_FLAG (1 << 5)
129 #define GLM_LANG_CXX14_FLAG (1 << 6)
130 #define GLM_LANG_CXX1Z_FLAG (1 << 7)
131 #define GLM_LANG_CXXMS_FLAG (1 << 8)
132 #define GLM_LANG_CXXGNU_FLAG (1 << 9)
133
134 #define GLM_LANG_CXX98 GLM_LANG_CXX98_FLAG
135 #define GLM_LANG_CXX03 (GLM_LANG_CXX98 | GLM_LANG_CXX03_FLAG)
136 #define GLM_LANG_CXX0X (GLM_LANG_CXX03 | GLM_LANG_CXX0X_FLAG)
137 #define GLM_LANG_CXX11 (GLM_LANG_CXX0X | GLM_LANG_CXX11_FLAG)
138 #define GLM_LANG_CXX1Y (GLM_LANG_CXX11 | GLM_LANG_CXX1Y_FLAG)
139 #define GLM_LANG_CXX14 (GLM_LANG_CXX1Y | GLM_LANG_CXX14_FLAG)
140 #define GLM_LANG_CXX1Z (GLM_LANG_CXX14 | GLM_LANG_CXX1Z_FLAG)
141 #define GLM_LANG_CXXMS GLM_LANG_CXXMS_FLAG
142 #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG
143
144 #if defined(GLM_FORCE_CXX14)
145 # if((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER <= GLM_COMPILER_GCC50)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER <= GLM_COMPILER_CLANG34))
146 # pragma message("GLM: Using GLM_FORCE_CXX14 with a compiler that doesn't fully support C++14")
147 # elif GLM_COMPILER & GLM_COMPILER_VC
148 # pragma message("GLM: Using GLM_FORCE_CXX14 but there is no known version of Visual C++ compiler that fully supports C++14")
149 # elif GLM_COMPILER & GLM_COMPILER_INTEL
150 # pragma message("GLM: Using GLM_FORCE_CXX14 but there is no known version of ICC compiler that fully supports C++14")
151 # endif
152 # define GLM_LANG GLM_LANG_CXX14
153 # define GLM_LANG_STL11_FORCED
154 #elif defined(GLM_FORCE_CXX11)
155 # if((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER <= GLM_COMPILER_GCC48)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER <= GLM_COMPILER_CLANG33))
156 # pragma message("GLM: Using GLM_FORCE_CXX11 with a compiler that doesn't fully support C++11")
157 # elif GLM_COMPILER & GLM_COMPILER_VC
158 # pragma message("GLM: Using GLM_FORCE_CXX11 but there is no known version of Visual C++ compiler that fully supports C++11")
159 # elif GLM_COMPILER & GLM_COMPILER_INTEL
160 # pragma message("GLM: Using GLM_FORCE_CXX11 but there is no known version of ICC compiler that fully supports C++11")
161 # endif
162 # define GLM_LANG GLM_LANG_CXX11
163 # define GLM_LANG_STL11_FORCED
164 #elif defined(GLM_FORCE_CXX03)
165 # define GLM_LANG GLM_LANG_CXX03
166 #elif defined(GLM_FORCE_CXX98)
167 # define GLM_LANG GLM_LANG_CXX98
168 #else
169 # if GLM_COMPILER & GLM_COMPILER_CLANG
170 # if __cplusplus >= 201402L // GLM_COMPILER_CLANG34 + -std=c++14
171 # define GLM_LANG GLM_LANG_CXX14
172 # elif __has_feature(cxx_decltype_auto) && __has_feature(cxx_aggregate_nsdmi) // GLM_COMPILER_CLANG33 + -std=c++1y
173 # define GLM_LANG GLM_LANG_CXX1Y
174 # elif __cplusplus >= 201103L // GLM_COMPILER_CLANG33 + -std=c++11
175 # define GLM_LANG GLM_LANG_CXX11
176 # elif __has_feature(cxx_static_assert) // GLM_COMPILER_CLANG29 + -std=c++11
177 # define GLM_LANG GLM_LANG_CXX0X
178 # elif __cplusplus >= 199711L
179 # define GLM_LANG GLM_LANG_CXX98
180 # else
181 # define GLM_LANG GLM_LANG_CXX
182 # endif
183 # elif GLM_COMPILER & GLM_COMPILER_GCC
184 # if __cplusplus >= 201402L
185 # define GLM_LANG GLM_LANG_CXX14
186 # elif __cplusplus >= 201103L
187 # define GLM_LANG GLM_LANG_CXX11
188 # elif defined(__GXX_EXPERIMENTAL_CXX0X__)
189 # define GLM_LANG GLM_LANG_CXX0X
190 # else
191 # define GLM_LANG GLM_LANG_CXX98
192 # endif
193 # elif GLM_COMPILER & GLM_COMPILER_VC
194 # ifdef _MSC_EXTENSIONS
195 # if __cplusplus >= 201402L
196 # define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_CXXMS_FLAG)
197 # elif __cplusplus >= 201103L
198 # define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_CXXMS_FLAG)
199 # else
200 # define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
201 # endif
202 # else
203 # if __cplusplus >= 201402L
204 # define GLM_LANG GLM_LANG_CXX14
205 # elif __cplusplus >= 201103L
206 # define GLM_LANG GLM_LANG_CXX11
207 # else
208 # define GLM_LANG GLM_LANG_CXX0X
209 # endif
210 # endif
211 # elif GLM_COMPILER & GLM_COMPILER_INTEL
212 # ifdef _MSC_EXTENSIONS
213 # define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
214 # else
215 # define GLM_MSC_EXT 0
216 # endif
217 # if __cplusplus >= 201402L
218 # define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT)
219 # elif __cplusplus >= 201103L
220 # define GLM_LANG (GLM_LANG_CXX11 | GLM_MSC_EXT)
221 # elif __INTEL_CXX11_MODE__
222 # define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT)
223 # elif __cplusplus >= 199711L
224 # define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT)
225 # else
226 # define GLM_LANG (GLM_LANG_CXX | GLM_MSC_EXT)
227 # endif
228 # elif GLM_COMPILER & GLM_COMPILER_CUDA
229 # ifdef _MSC_EXTENSIONS
230 # define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG
231 # else
232 # define GLM_MSC_EXT 0
233 # endif
234 # if GLM_COMPILER >= GLM_COMPILER_CUDA75
235 # define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT)
236 # else
237 # define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT)
238 # endif
239 # else // Unknown compiler
240 # if __cplusplus >= 201402L
241 # define GLM_LANG GLM_LANG_CXX14
242 # elif __cplusplus >= 201103L
243 # define GLM_LANG GLM_LANG_CXX11
244 # elif __cplusplus >= 199711L
245 # define GLM_LANG GLM_LANG_CXX98
246 # else
247 # define GLM_LANG GLM_LANG_CXX // Good luck with that!
248 # endif
249 # ifndef GLM_FORCE_PURE
250 # define GLM_FORCE_PURE
251 # endif
252 # endif
253 #endif
254
255 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_LANG_DISPLAYED)
256 # define GLM_MESSAGE_LANG_DISPLAYED
257
258 # if GLM_LANG & GLM_LANG_CXX1Z_FLAG
259 # pragma message("GLM: C++1z")
260 # elif GLM_LANG & GLM_LANG_CXX14_FLAG
261 # pragma message("GLM: C++14")
262 # elif GLM_LANG & GLM_LANG_CXX1Y_FLAG
263 # pragma message("GLM: C++1y")
264 # elif GLM_LANG & GLM_LANG_CXX11_FLAG
265 # pragma message("GLM: C++11")
266 # elif GLM_LANG & GLM_LANG_CXX0X_FLAG
267 # pragma message("GLM: C++0x")
268 # elif GLM_LANG & GLM_LANG_CXX03_FLAG
269 # pragma message("GLM: C++03")
270 # elif GLM_LANG & GLM_LANG_CXX98_FLAG
271 # pragma message("GLM: C++98")
272 # else
273 # pragma message("GLM: C++ language undetected")
274 # endif//GLM_LANG
275
276 # if GLM_LANG & (GLM_LANG_CXXGNU_FLAG | GLM_LANG_CXXMS_FLAG)
277 # pragma message("GLM: Language extensions enabled")
278 # endif//GLM_LANG
279 #endif//GLM_MESSAGES
280
282 // Has of C++ features
283
284 // http://clang.llvm.org/cxx_status.html
285 // http://gcc.gnu.org/projects/cxx0x.html
286 // http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
287
288 // Android has multiple STLs but C++11 STL detection doesn't always work #284 #564
289 #if GLM_PLATFORM == GLM_PLATFORM_ANDROID && !defined(GLM_LANG_STL11_FORCED)
290 # define GLM_HAS_CXX11_STL 0
291 #elif GLM_COMPILER & GLM_COMPILER_CLANG
292 # if (defined(_LIBCPP_VERSION) && GLM_LANG & GLM_LANG_CXX11_FLAG) || defined(GLM_LANG_STL11_FORCED)
293 # define GLM_HAS_CXX11_STL 1
294 # else
295 # define GLM_HAS_CXX11_STL 0
296 # endif
297 #else
298 # define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
299 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
300 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
301 ((GLM_PLATFORM != GLM_PLATFORM_WINDOWS) && (GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15))))
302 #endif
303
304 // N1720
305 #if GLM_COMPILER & GLM_COMPILER_CLANG
306 # define GLM_HAS_STATIC_ASSERT __has_feature(cxx_static_assert)
307 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
308 # define GLM_HAS_STATIC_ASSERT 1
309 #else
310 # define GLM_HAS_STATIC_ASSERT ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
311 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
312 ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \
313 ((GLM_COMPILER & GLM_COMPILER_VC))))
314 #endif
315
316 // N1988
317 #if GLM_LANG & GLM_LANG_CXX11_FLAG
318 # define GLM_HAS_EXTENDED_INTEGER_TYPE 1
319 #else
320 # define GLM_HAS_EXTENDED_INTEGER_TYPE (\
321 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC)) || \
322 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CUDA)) || \
323 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC)) || \
324 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CLANG)))
325 #endif
326
327 // N2235
328 #if GLM_COMPILER & GLM_COMPILER_CLANG
329 # define GLM_HAS_CONSTEXPR __has_feature(cxx_constexpr)
330 # define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR
331 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
332 # define GLM_HAS_CONSTEXPR 1
333 # define GLM_HAS_CONSTEXPR_PARTIAL GLM_HAS_CONSTEXPR
334 #else
335 # define GLM_HAS_CONSTEXPR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
336 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)) || \
337 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)))) // GCC 4.6 support constexpr but there is a compiler bug causing a crash
338 # define GLM_HAS_CONSTEXPR_PARTIAL (GLM_HAS_CONSTEXPR || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)))
339 #endif
340
341 // N2672
342 #if GLM_COMPILER & GLM_COMPILER_CLANG
343 # define GLM_HAS_INITIALIZER_LISTS __has_feature(cxx_generalized_initializers)
344 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
345 # define GLM_HAS_INITIALIZER_LISTS 1
346 #else
347 # define GLM_HAS_INITIALIZER_LISTS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
348 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
349 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
350 ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA75))))
351 #endif
352
353 // N2544 Unrestricted unions http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
354 #if GLM_COMPILER & GLM_COMPILER_CLANG
355 # define GLM_HAS_UNRESTRICTED_UNIONS __has_feature(cxx_unrestricted_unions)
356 #elif GLM_LANG & (GLM_LANG_CXX11_FLAG | GLM_LANG_CXXMS_FLAG)
357 # define GLM_HAS_UNRESTRICTED_UNIONS 1
358 #else
359 # define GLM_HAS_UNRESTRICTED_UNIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
360 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_LANG & GLM_LANG_CXXMS_FLAG)) || \
361 ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA75)) || \
362 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)))
363 #endif
364
365 // N2346
366 #if defined(GLM_FORCE_UNRESTRICTED_GENTYPE)
367 # define GLM_HAS_DEFAULTED_FUNCTIONS 0
368 #elif GLM_COMPILER & GLM_COMPILER_CLANG
369 # define GLM_HAS_DEFAULTED_FUNCTIONS __has_feature(cxx_defaulted_functions)
370 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
371 # define GLM_HAS_DEFAULTED_FUNCTIONS 1
372 #else
373 # define GLM_HAS_DEFAULTED_FUNCTIONS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
374 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
375 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
376 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
377 (GLM_COMPILER & GLM_COMPILER_CUDA)))
378 #endif
379
380 // N2118
381 #if GLM_COMPILER & GLM_COMPILER_CLANG
382 # define GLM_HAS_RVALUE_REFERENCES __has_feature(cxx_rvalue_references)
383 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
384 # define GLM_HAS_RVALUE_REFERENCES 1
385 #else
386 # define GLM_HAS_RVALUE_REFERENCES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
387 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
388 ((GLM_COMPILER & GLM_COMPILER_VC)) || \
389 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
390 #endif
391
392 // N2437 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
393 #if GLM_COMPILER & GLM_COMPILER_CLANG
394 # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS __has_feature(cxx_explicit_conversions)
395 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
396 # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS 1
397 #else
398 # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
399 ((GLM_COMPILER & GLM_COMPILER_GCC)) || \
400 ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \
401 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
402 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
403 #endif
404
405 // N2258 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
406 #if GLM_COMPILER & GLM_COMPILER_CLANG
407 # define GLM_HAS_TEMPLATE_ALIASES __has_feature(cxx_alias_templates)
408 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
409 # define GLM_HAS_TEMPLATE_ALIASES 1
410 #else
411 # define GLM_HAS_TEMPLATE_ALIASES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
412 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
413 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \
414 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
415 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
416 #endif
417
418 // N2930 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html
419 #if GLM_COMPILER & GLM_COMPILER_CLANG
420 # define GLM_HAS_RANGE_FOR __has_feature(cxx_range_for)
421 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
422 # define GLM_HAS_RANGE_FOR 1
423 #else
424 # define GLM_HAS_RANGE_FOR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
425 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \
426 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
427 ((GLM_COMPILER & GLM_COMPILER_VC)) || \
428 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
429 #endif
430
431 // N2341 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
432 #if GLM_COMPILER & GLM_COMPILER_CLANG
433 # define GLM_HAS_ALIGNOF __has_feature(c_alignof)
434 #elif GLM_LANG & GLM_LANG_CXX11_FLAG
435 # define GLM_HAS_ALIGNOF 1
436 #else
437 # define GLM_HAS_ALIGNOF ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
438 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
439 ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)) || \
440 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)) || \
441 ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA70))))
442 #endif
443
444 #define GLM_HAS_ONLY_XYZW ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC46))
445 #if GLM_HAS_ONLY_XYZW
446 # pragma message("GLM: GCC older than 4.6 has a bug presenting the use of rgba and stpq components")
447 #endif
448
449 //
450 #if GLM_LANG & GLM_LANG_CXX11_FLAG
451 # define GLM_HAS_ASSIGNABLE 1
452 #else
453 # define GLM_HAS_ASSIGNABLE ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
454 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)) || \
455 ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49))))
456 #endif
457
458 //
459 #define GLM_HAS_TRIVIAL_QUERIES 0
460
461 //
462 #if GLM_LANG & GLM_LANG_CXX11_FLAG
463 # define GLM_HAS_MAKE_SIGNED 1
464 #else
465 # define GLM_HAS_MAKE_SIGNED ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
466 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \
467 ((GLM_COMPILER & GLM_COMPILER_CUDA))))
468 #endif
469
470 #if GLM_ARCH == GLM_ARCH_PURE
471 # define GLM_HAS_BITSCAN_WINDOWS 0
472 #else
473 # define GLM_HAS_BITSCAN_WINDOWS ((GLM_PLATFORM & GLM_PLATFORM_WINDOWS) && (\
474 ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \
475 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14) && (GLM_ARCH & GLM_ARCH_X86_BIT))))
476 #endif
477
478 // OpenMP
479 #ifdef _OPENMP
480 # if GLM_COMPILER & GLM_COMPILER_GCC
481 # if GLM_COMPILER >= GLM_COMPILER_GCC61
482 # define GLM_HAS_OPENMP 45
483 # elif GLM_COMPILER >= GLM_COMPILER_GCC49
484 # define GLM_HAS_OPENMP 40
485 # elif GLM_COMPILER >= GLM_COMPILER_GCC47
486 # define GLM_HAS_OPENMP 31
487 # else
488 # define GLM_HAS_OPENMP 0
489 # endif
490 # elif GLM_COMPILER & GLM_COMPILER_CLANG
491 # if GLM_COMPILER >= GLM_COMPILER_CLANG38
492 # define GLM_HAS_OPENMP 31
493 # else
494 # define GLM_HAS_OPENMP 0
495 # endif
496 # elif GLM_COMPILER & GLM_COMPILER_VC
497 # define GLM_HAS_OPENMP 20
498 # elif GLM_COMPILER & GLM_COMPILER_INTEL
499 # if GLM_COMPILER >= GLM_COMPILER_INTEL16
500 # define GLM_HAS_OPENMP 40
501 # else
502 # define GLM_HAS_OPENMP 0
503 # endif
504 # else
505 # define GLM_HAS_OPENMP 0
506 # endif
507 #else
508 # define GLM_HAS_OPENMP 0
509 #endif
510
512 // nullptr
513
514 //
515 #if GLM_LANG & GLM_LANG_CXX0X_FLAG
516 # define GLM_HAS_NULLPTR 1
517 #else
518 # define GLM_HAS_NULLPTR 0
519 #endif
520
521 #if GLM_HAS_NULLPTR
522 # define GLM_NULLPTR nullptr
523 #else
524 # define GLM_NULLPTR 0
525 #endif
526
528 // Static assert
529
530 #if GLM_HAS_STATIC_ASSERT
531 # define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
532 #elif GLM_COMPILER & GLM_COMPILER_VC
533 # define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
534 #else
535 # define GLM_STATIC_ASSERT(x, message)
536 # define GLM_STATIC_ASSERT_NULL
537 #endif//GLM_LANG
538
540 // Qualifiers
541
542 #if GLM_COMPILER & GLM_COMPILER_CUDA
543 # define GLM_CUDA_FUNC_DEF __device__ __host__
544 # define GLM_CUDA_FUNC_DECL __device__ __host__
545 #else
546 # define GLM_CUDA_FUNC_DEF
547 # define GLM_CUDA_FUNC_DECL
548 #endif
549
550 #if GLM_COMPILER & GLM_COMPILER_GCC
551 # define GLM_VAR_USED __attribute__ ((unused))
552 #else
553 # define GLM_VAR_USED
554 #endif
555
556 #if defined(GLM_FORCE_INLINE)
557 # if GLM_COMPILER & GLM_COMPILER_VC
558 # define GLM_INLINE __forceinline
559 # define GLM_NEVER_INLINE __declspec((noinline))
560 # elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)
561 # define GLM_INLINE inline __attribute__((__always_inline__))
562 # define GLM_NEVER_INLINE __attribute__((__noinline__))
563 # elif GLM_COMPILER & GLM_COMPILER_CUDA
564 # define GLM_INLINE __forceinline__
565 # define GLM_NEVER_INLINE __noinline__
566 # else
567 # define GLM_INLINE inline
568 # define GLM_NEVER_INLINE
569 # endif//GLM_COMPILER
570 #else
571 # define GLM_INLINE inline
572 # define GLM_NEVER_INLINE
573 #endif//defined(GLM_FORCE_INLINE)
574
575 #define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL
576 #define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE
577
579 // Swizzle operators
580
581 // User defines: GLM_FORCE_SWIZZLE
582
583 #define GLM_SWIZZLE_ENABLED 1
584 #define GLM_SWIZZLE_DISABLE 0
585
586 #if defined(GLM_FORCE_SWIZZLE)
587 # define GLM_SWIZZLE GLM_SWIZZLE_ENABLED
588 #else
589 # define GLM_SWIZZLE GLM_SWIZZLE_DISABLE
590 #endif
591
592 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)
593 # define GLM_MESSAGE_SWIZZLE_DISPLAYED
594 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
595 # pragma message("GLM: Swizzling operators enabled")
596 # else
597 # pragma message("GLM: Swizzling operators disabled, #define GLM_SWIZZLE to enable swizzle operators")
598 # endif
599 #endif//GLM_MESSAGES
600
602 // Allows using not basic types as genType
603
604 // #define GLM_FORCE_UNRESTRICTED_GENTYPE
605
606 #ifdef GLM_FORCE_UNRESTRICTED_GENTYPE
607 # define GLM_UNRESTRICTED_GENTYPE 1
608 #else
609 # define GLM_UNRESTRICTED_GENTYPE 0
610 #endif
611
612 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED)
613 # define GLM_MESSAGE_UNRESTRICTED_GENTYPE_DISPLAYED
614 # ifdef GLM_FORCE_UNRESTRICTED_GENTYPE
615 # pragma message("GLM: Use unrestricted genType")
616 # endif
617 #endif//GLM_MESSAGES
618
620 // Force single only (remove explicit float64 types)
621
622 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_SINGLE_ONLY_DISPLAYED)
623 # define GLM_MESSAGE_SINGLE_ONLY_DISPLAYED
624 # ifdef GLM_FORCE_SINGLE_ONLY
625 # pragma message("GLM: Using only single precision floating-point types")
626 # endif
627 #endif//GLM_MESSAGES
628
630 // Clip control
631
632 #define GLM_DEPTH_ZERO_TO_ONE 0x00000001
633 #define GLM_DEPTH_NEGATIVE_ONE_TO_ONE 0x00000002
634
635 #ifdef GLM_FORCE_DEPTH_ZERO_TO_ONE
636 # define GLM_DEPTH_CLIP_SPACE GLM_DEPTH_ZERO_TO_ONE
637 #else
638 # define GLM_DEPTH_CLIP_SPACE GLM_DEPTH_NEGATIVE_ONE_TO_ONE
639 #endif
640
641 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_DEPTH_DISPLAYED)
642 # define GLM_MESSAGE_DEPTH_DISPLAYED
643 # if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE
644 # pragma message("GLM: Depth clip space: Zero to one")
645 # else
646 # pragma message("GLM: Depth clip space: negative one to one")
647 # endif
648 #endif//GLM_MESSAGES
649
651 // Coordinate system, define GLM_FORCE_LEFT_HANDED before including GLM
652 // to use left handed coordinate system by default.
653
654 #define GLM_LEFT_HANDED 0x00000001 // For DirectX, Metal, Vulkan
655 #define GLM_RIGHT_HANDED 0x00000002 // For OpenGL, default in GLM
656
657 #ifdef GLM_FORCE_LEFT_HANDED
658 # define GLM_COORDINATE_SYSTEM GLM_LEFT_HANDED
659 #else
660 # define GLM_COORDINATE_SYSTEM GLM_RIGHT_HANDED
661 #endif
662
663 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_HANDED_DISPLAYED)
664 # define GLM_MESSAGE_HANDED_DISPLAYED
665 # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED
666 # pragma message("GLM: Coordinate system: left handed")
667 # else
668 # pragma message("GLM: Coordinate system: right handed")
669 # endif
670 #endif//GLM_MESSAGES
671
673 // Qualifiers
674
675 #if (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))
676 # define GLM_DEPRECATED __declspec(deprecated)
677 # define GLM_ALIGN(x) __declspec(align(x))
678 # define GLM_ALIGNED_STRUCT(x) struct __declspec(align(x))
679 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef __declspec(align(alignment)) type name
680 # define GLM_RESTRICT_FUNC __declspec(restrict)
681 # define GLM_RESTRICT __restrict
682 # if GLM_COMPILER >= GLM_COMPILER_VC12
683 # define GLM_VECTOR_CALL __vectorcall
684 # else
685 # define GLM_VECTOR_CALL
686 # endif
687 #elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG | GLM_COMPILER_INTEL)
688 # define GLM_DEPRECATED __attribute__((__deprecated__))
689 # define GLM_ALIGN(x) __attribute__((aligned(x)))
690 # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
691 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name __attribute__((aligned(alignment)))
692 # define GLM_RESTRICT_FUNC __restrict__
693 # define GLM_RESTRICT __restrict__
694 # if GLM_COMPILER & GLM_COMPILER_CLANG
695 # if GLM_COMPILER >= GLM_COMPILER_CLANG37
696 # define GLM_VECTOR_CALL __vectorcall
697 # else
698 # define GLM_VECTOR_CALL
699 # endif
700 # else
701 # define GLM_VECTOR_CALL
702 # endif
703 #elif GLM_COMPILER & GLM_COMPILER_CUDA
704 # define GLM_DEPRECATED
705 # define GLM_ALIGN(x) __align__(x)
706 # define GLM_ALIGNED_STRUCT(x) struct __align__(x)
707 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name __align__(x)
708 # define GLM_RESTRICT_FUNC __restrict__
709 # define GLM_RESTRICT __restrict__
710 # define GLM_VECTOR_CALL
711 #else
712 # define GLM_DEPRECATED
713 # define GLM_ALIGN
714 # define GLM_ALIGNED_STRUCT(x) struct
715 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name
716 # define GLM_RESTRICT_FUNC
717 # define GLM_RESTRICT
718 # define GLM_VECTOR_CALL
719 #endif//GLM_COMPILER
720
721 #if GLM_HAS_DEFAULTED_FUNCTIONS
722 # define GLM_DEFAULT = default
723
724 # ifdef GLM_FORCE_NO_CTOR_INIT
725 # undef GLM_FORCE_CTOR_INIT
726 # endif
727
728 # ifdef GLM_FORCE_CTOR_INIT
729 # define GLM_DEFAULT_CTOR
730 # else
731 # define GLM_DEFAULT_CTOR = default
732 # endif
733 #else
734 # define GLM_DEFAULT
735 # define GLM_DEFAULT_CTOR
736 #endif
737
738 #if GLM_HAS_CONSTEXPR || GLM_HAS_CONSTEXPR_PARTIAL
739 # define GLM_CONSTEXPR constexpr
740 # if ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER <= GLM_COMPILER_VC14)) // Visual C++ has a bug #594 https://github.com/g-truc/glm/issues/594
741 # define GLM_CONSTEXPR_CTOR
742 # else
743 # define GLM_CONSTEXPR_CTOR constexpr
744 # endif
745 #else
746 # define GLM_CONSTEXPR
747 # define GLM_CONSTEXPR_CTOR
748 #endif
749
750 #if GLM_HAS_CONSTEXPR
751 # define GLM_RELAXED_CONSTEXPR constexpr
752 #else
753 # define GLM_RELAXED_CONSTEXPR const
754 #endif
755
756 #if GLM_LANG >= GLM_LANG_CXX14
757 # if ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER <= GLM_COMPILER_VC14)) // Visual C++ < 2017 does not support extended const expressions https://msdn.microsoft.com/en-us/library/hh567368.aspx https://github.com/g-truc/glm/issues/749
758 # define GLM_CONSTEXPR_CXX14
759 # else
760 # define GLM_CONSTEXPR_CXX14 GLM_CONSTEXPR
761 # endif
762 # define GLM_CONSTEXPR_CTOR_CXX14 GLM_CONSTEXPR_CTOR
763 #else
764 # define GLM_CONSTEXPR_CXX14
765 # define GLM_CONSTEXPR_CTOR_CXX14
766 #endif
767
768 #if GLM_ARCH == GLM_ARCH_PURE
769 # define GLM_CONSTEXPR_SIMD GLM_CONSTEXPR_CTOR
770 #else
771 # define GLM_CONSTEXPR_SIMD
772 #endif
773
774 #ifdef GLM_FORCE_EXPLICIT_CTOR
775 # define GLM_EXPLICIT explicit
776 #else
777 # define GLM_EXPLICIT
778 #endif
779
781
782 #define GLM_HAS_ALIGNED_TYPE GLM_HAS_UNRESTRICTED_UNIONS
783
785 // Length type: all length functions returns a length_t type.
786 // When GLM_FORCE_SIZE_T_LENGTH is defined, length_t is a typedef of size_t otherwise
787 // length_t is a typedef of int like GLSL defines it.
788
789 // User define: GLM_FORCE_SIZE_T_LENGTH
790
791 namespace glm
792 {
793 using std::size_t;
794 # if defined(GLM_FORCE_SIZE_T_LENGTH)
795 typedef size_t length_t;
796 # else
797 typedef int length_t;
798 # endif
799 }//namespace glm
800
801 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_SIZE_T_LENGTH)
802 # define GLM_MESSAGE_FORCE_SIZE_T_LENGTH
803 # if defined GLM_FORCE_SIZE_T_LENGTH
804 # pragma message("GLM: .length() returns glm::length_t, a typedef of std::size_t")
805 # else
806 # pragma message("GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification")
807 # endif
808 #endif//GLM_MESSAGES
809
811 // countof
812
813 #if GLM_HAS_CONSTEXPR_PARTIAL
814 namespace glm
815 {
816 template<typename T, std::size_t N>
817 constexpr std::size_t countof(T const (&)[N])
818 {
819 return N;
820 }
821 }//namespace glm
822 # define GLM_COUNTOF(arr) glm::countof(arr)
823 #elif defined(_MSC_VER)
824 # define GLM_COUNTOF(arr) _countof(arr)
825 #else
826 # define GLM_COUNTOF(arr) sizeof(arr) / sizeof(arr[0])
827 #endif
828
830 // Check inclusions of different versions of GLM
831
832 #elif ((GLM_SETUP_INCLUDED != GLM_VERSION) && !defined(GLM_FORCE_IGNORE_VERSION))
833 # error "GLM error: A different version of GLM is already included. Define GLM_FORCE_IGNORE_VERSION before including GLM headers to ignore this error."
834 #elif GLM_SETUP_INCLUDED == GLM_VERSION
835
836 #endif//GLM_SETUP_INCLUDED
glm
Definition: common.hpp:20