GLM  0.9.5
setup.hpp
1 
29 #ifndef GLM_SETUP_INCLUDED
30 #define GLM_SETUP_INCLUDED
31 
32 #include <cassert>
33 
35 // Version
36 
37 #define GLM_VERSION 95
38 #define GLM_VERSION_MAJOR 0
39 #define GLM_VERSION_MINOR 9
40 #define GLM_VERSION_PATCH 5
41 #define GLM_VERSION_REVISION 0
42 
44 // Platform
45 
46 #define GLM_PLATFORM_UNKNOWN 0x00000000
47 #define GLM_PLATFORM_WINDOWS 0x00010000
48 #define GLM_PLATFORM_LINUX 0x00020000
49 #define GLM_PLATFORM_APPLE 0x00040000
50 //#define GLM_PLATFORM_IOS 0x00080000
51 #define GLM_PLATFORM_ANDROID 0x00100000
52 #define GLM_PLATFORM_CHROME_NACL 0x00200000
53 #define GLM_PLATFORM_UNIX 0x00400000
54 #define GLM_PLATFORM_QNXNTO 0x00800000
55 #define GLM_PLATFORM_WINCE 0x01000000
56 
57 #ifdef GLM_FORCE_PLATFORM_UNKNOWN
58 # define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
59 #elif defined(__QNXNTO__)
60 # define GLM_PLATFORM GLM_PLATFORM_QNXNTO
61 #elif defined(__APPLE__)
62 # define GLM_PLATFORM GLM_PLATFORM_APPLE
63 #elif defined(WINCE)
64 # define GLM_PLATFORM GLM_PLATFORM_WINCE
65 #elif defined(_WIN32)
66 # define GLM_PLATFORM GLM_PLATFORM_WINDOWS
67 #elif defined(__native_client__)
68 # define GLM_PLATFORM GLM_PLATFORM_CHROME_NACL
69 #elif defined(__ANDROID__)
70 # define GLM_PLATFORM GLM_PLATFORM_ANDROID
71 #elif defined(__linux)
72 # define GLM_PLATFORM GLM_PLATFORM_LINUX
73 #elif defined(__unix)
74 # define GLM_PLATFORM GLM_PLATFORM_UNIX
75 #else
76 # define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
77 #endif//
78 
79 // Report platform detection
80 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_PLATFORM_DISPLAYED))
81 # define GLM_MESSAGE_PLATFORM_DISPLAYED
82 # if(GLM_PLATFORM & GLM_PLATFORM_QNXNTO)
83 # pragma message("GLM: QNX platform detected")
84 //# elif(GLM_PLATFORM & GLM_PLATFORM_IOS)
85 //# pragma message("GLM: iOS platform detected")
86 # elif(GLM_PLATFORM & GLM_PLATFORM_APPLE)
87 # pragma message("GLM: Apple platform detected")
88 # elif(GLM_PLATFORM & GLM_PLATFORM_WINCE)
89 # pragma message("GLM: WinCE platform detected")
90 # elif(GLM_PLATFORM & GLM_PLATFORM_WINDOWS)
91 # pragma message("GLM: Windows platform detected")
92 # elif(GLM_PLATFORM & GLM_PLATFORM_CHROME_NACL)
93 # pragma message("GLM: Native Client detected")
94 # elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
95 # pragma message("GLM: Android platform detected")
96 # elif(GLM_PLATFORM & GLM_PLATFORM_LINUX)
97 # pragma message("GLM: Linux platform detected")
98 # elif(GLM_PLATFORM & GLM_PLATFORM_UNIX)
99 # pragma message("GLM: UNIX platform detected")
100 # elif(GLM_PLATFORM & GLM_PLATFORM_UNKNOWN)
101 # pragma message("GLM: platform unknown")
102 # else
103 # pragma message("GLM: platform not detected")
104 # endif
105 #endif//GLM_MESSAGE
106 
108 // Compiler
109 
110 // User defines: GLM_FORCE_COMPILER_UNKNOWN
111 // TODO ? __llvm__
112 
113 #define GLM_COMPILER_UNKNOWN 0x00000000
114 
115 // Intel
116 #define GLM_COMPILER_INTEL 0x00100000
117 #define GLM_COMPILER_INTEL9 0x00100010
118 #define GLM_COMPILER_INTEL10_0 0x00100020
119 #define GLM_COMPILER_INTEL10_1 0x00100030
120 #define GLM_COMPILER_INTEL11_0 0x00100040
121 #define GLM_COMPILER_INTEL11_1 0x00100050
122 #define GLM_COMPILER_INTEL12_0 0x00100060
123 #define GLM_COMPILER_INTEL12_1 0x00100070
124 #define GLM_COMPILER_INTEL13_0 0x00100080
125 
126 // Visual C++ defines
127 #define GLM_COMPILER_VC 0x01000000
128 #define GLM_COMPILER_VC8 0x01000070
129 #define GLM_COMPILER_VC9 0x01000080
130 #define GLM_COMPILER_VC10 0x01000090
131 #define GLM_COMPILER_VC11 0x010000A0
132 #define GLM_COMPILER_VC12 0x010000B0
133 
134 // GCC defines
135 #define GLM_COMPILER_GCC 0x02000000
136 #define GLM_COMPILER_GCC34 0x02000050
137 #define GLM_COMPILER_GCC35 0x02000060
138 #define GLM_COMPILER_GCC40 0x02000070
139 #define GLM_COMPILER_GCC41 0x02000080
140 #define GLM_COMPILER_GCC42 0x02000090
141 #define GLM_COMPILER_GCC43 0x020000A0
142 #define GLM_COMPILER_GCC44 0x020000B0
143 #define GLM_COMPILER_GCC45 0x020000C0
144 #define GLM_COMPILER_GCC46 0x020000D0
145 #define GLM_COMPILER_GCC47 0x020000E0
146 #define GLM_COMPILER_GCC48 0x020000F0
147 #define GLM_COMPILER_GCC49 0x02000100
148 
149 // Borland C++
150 #define GLM_COMPILER_BC 0x04000000
151 
152 // CodeWarrior
153 #define GLM_COMPILER_CODEWARRIOR 0x08000000
154 
155 // CUDA
156 #define GLM_COMPILER_CUDA 0x10000000
157 #define GLM_COMPILER_CUDA30 0x10000010
158 #define GLM_COMPILER_CUDA31 0x10000020
159 #define GLM_COMPILER_CUDA32 0x10000030
160 #define GLM_COMPILER_CUDA40 0x10000040
161 #define GLM_COMPILER_CUDA41 0x10000050
162 #define GLM_COMPILER_CUDA42 0x10000060
163 
164 // Clang
165 #define GLM_COMPILER_CLANG 0x20000000
166 #define GLM_COMPILER_CLANG26 0x20000010
167 #define GLM_COMPILER_CLANG27 0x20000020
168 #define GLM_COMPILER_CLANG28 0x20000030
169 #define GLM_COMPILER_CLANG29 0x20000040
170 #define GLM_COMPILER_CLANG30 0x20000050
171 #define GLM_COMPILER_CLANG31 0x20000060
172 #define GLM_COMPILER_CLANG32 0x20000070
173 #define GLM_COMPILER_CLANG33 0x20000080
174 #define GLM_COMPILER_CLANG40 0x20000090
175 #define GLM_COMPILER_CLANG41 0x200000A0
176 #define GLM_COMPILER_CLANG42 0x200000B0
177 #define GLM_COMPILER_CLANG43 0x200000C0
178 #define GLM_COMPILER_CLANG50 0x200000D0
179 
180 // LLVM GCC
181 #define GLM_COMPILER_LLVM_GCC 0x40000000
182 
183 // Build model
184 #define GLM_MODEL_32 0x00000010
185 #define GLM_MODEL_64 0x00000020
186 
187 // Force generic C++ compiler
188 #ifdef GLM_FORCE_COMPILER_UNKNOWN
189 # define GLM_COMPILER GLM_COMPILER_UNKNOWN
190 
191 #elif defined(__INTEL_COMPILER)
192 # if __INTEL_COMPILER == 900
193 # define GLM_COMPILER GLM_COMPILER_INTEL9
194 # elif __INTEL_COMPILER == 1000
195 # define GLM_COMPILER GLM_COMPILER_INTEL10_0
196 # elif __INTEL_COMPILER == 1010
197 # define GLM_COMPILER GLM_COMPILER_INTEL10_1
198 # elif __INTEL_COMPILER == 1100
199 # define GLM_COMPILER GLM_COMPILER_INTEL11_0
200 # elif __INTEL_COMPILER == 1110
201 # define GLM_COMPILER GLM_COMPILER_INTEL11_1
202 # elif __INTEL_COMPILER == 1200
203 # define GLM_COMPILER GLM_COMPILER_INTEL12_0
204 # elif __INTEL_COMPILER == 1210
205 # define GLM_COMPILER GLM_COMPILER_INTEL12_1
206 # elif __INTEL_COMPILER >= 1300
207 # define GLM_COMPILER GLM_COMPILER_INTEL13_0
208 # else
209 # define GLM_COMPILER GLM_COMPILER_INTEL
210 # endif
211 
212 // CUDA
213 #elif defined(__CUDACC__)
214 # if CUDA_VERSION < 3000
215 # error "GLM requires CUDA 3.0 or higher"
216 # else
217 # define GLM_COMPILER GLM_COMPILER_CUDA
218 # endif
219 
220 // Visual C++
221 #elif defined(_MSC_VER)
222 # if _MSC_VER < 1400
223 # error "GLM requires Visual C++ 2005 or higher"
224 # elif _MSC_VER == 1400
225 # define GLM_COMPILER GLM_COMPILER_VC8
226 # elif _MSC_VER == 1500
227 # define GLM_COMPILER GLM_COMPILER_VC9
228 # elif _MSC_VER == 1600
229 # define GLM_COMPILER GLM_COMPILER_VC10
230 # elif _MSC_VER == 1700
231 # define GLM_COMPILER GLM_COMPILER_VC11
232 # elif _MSC_VER >= 1800
233 # define GLM_COMPILER GLM_COMPILER_VC12
234 # else//_MSC_VER
235 # define GLM_COMPILER GLM_COMPILER_VC
236 # endif//_MSC_VER
237 
238 // Clang
239 #elif defined(__clang__)
240 # if (__clang_major__ <= 1) || ((__clang_major__ == 2) && (__clang_minor__ < 6))
241 # error "GLM requires Clang 2.6 or higher"
242 # elif(__clang_major__ == 2) && (__clang_minor__ == 6)
243 # define GLM_COMPILER GLM_COMPILER_CLANG26
244 # elif(__clang_major__ == 2) && (__clang_minor__ == 7)
245 # define GLM_COMPILER GLM_COMPILER_CLANG27
246 # elif(__clang_major__ == 2) && (__clang_minor__ == 8)
247 # define GLM_COMPILER GLM_COMPILER_CLANG28
248 # elif(__clang_major__ == 2) && (__clang_minor__ == 9)
249 # define GLM_COMPILER GLM_COMPILER_CLANG29
250 # elif(__clang_major__ == 3) && (__clang_minor__ == 0)
251 # define GLM_COMPILER GLM_COMPILER_CLANG30
252 # elif(__clang_major__ == 3) && (__clang_minor__ == 1)
253 # define GLM_COMPILER GLM_COMPILER_CLANG31
254 # elif(__clang_major__ == 3) && (__clang_minor__ == 2)
255 # define GLM_COMPILER GLM_COMPILER_CLANG32
256 # elif(__clang_major__ == 3) && (__clang_minor__ == 3)
257 # define GLM_COMPILER GLM_COMPILER_CLANG33
258 # elif(__clang_major__ == 4) && (__clang_minor__ == 0)
259 # define GLM_COMPILER GLM_COMPILER_CLANG40
260 # elif(__clang_major__ == 4) && (__clang_minor__ == 1)
261 # define GLM_COMPILER GLM_COMPILER_CLANG41
262 # elif(__clang_major__ == 4) && (__clang_minor__ == 2)
263 # define GLM_COMPILER GLM_COMPILER_CLANG42
264 # elif(__clang_major__ == 4) && (__clang_minor__ >= 3)
265 # define GLM_COMPILER GLM_COMPILER_CLANG43
266 # elif(__clang_major__ > 4)
267 # define GLM_COMPILER GLM_COMPILER_CLANG50
268 # else
269 # define GLM_COMPILER GLM_COMPILER_CLANG
270 # endif
271 
272 // G++
273 #elif(defined(__GNUC__) || defined(__MINGW32__))// || defined(__llvm__) || defined(__clang__)
274 # if (__GNUC__ == 3) && (__GNUC_MINOR__ == 4)
275 # define GLM_COMPILER GLM_COMPILER_GCC34
276 # elif (__GNUC__ == 3) && (__GNUC_MINOR__ == 5)
277 # define GLM_COMPILER GLM_COMPILER_GCC35
278 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 0)
279 # define GLM_COMPILER (GLM_COMPILER_GCC40)
280 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 1)
281 # define GLM_COMPILER (GLM_COMPILER_GCC41)
282 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
283 # define GLM_COMPILER (GLM_COMPILER_GCC42)
284 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
285 # define GLM_COMPILER (GLM_COMPILER_GCC43)
286 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
287 # define GLM_COMPILER (GLM_COMPILER_GCC44)
288 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 5)
289 # define GLM_COMPILER (GLM_COMPILER_GCC45)
290 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
291 # define GLM_COMPILER (GLM_COMPILER_GCC46)
292 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
293 # define GLM_COMPILER (GLM_COMPILER_GCC47)
294 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
295 # define GLM_COMPILER (GLM_COMPILER_GCC48)
296 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)
297 # define GLM_COMPILER (GLM_COMPILER_GCC49)
298 # elif (__GNUC__ > 4 )
299 # define GLM_COMPILER (GLM_COMPILER_GCC49)
300 # else
301 # define GLM_COMPILER (GLM_COMPILER_GCC)
302 # endif
303 
304 // Borland C++
305 #elif defined(_BORLANDC_)
306 # define GLM_COMPILER GLM_COMPILER_BC
307 
308 // Codewarrior
309 #elif defined(__MWERKS__)
310 # define GLM_COMPILER GLM_COMPILER_CODEWARRIOR
311 
312 #else
313 # define GLM_COMPILER GLM_COMPILER_UNKNOWN
314 #endif
315 
316 #ifndef GLM_COMPILER
317 #error "GLM_COMPILER undefined, your compiler may not be supported by GLM. Add #define GLM_COMPILER 0 to ignore this message."
318 #endif//GLM_COMPILER
319 
320 // Report compiler detection
321 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPILER_DISPLAYED))
322 # define GLM_MESSAGE_COMPILER_DISPLAYED
323 # if(GLM_COMPILER & GLM_COMPILER_CUDA)
324 # pragma message("GLM: CUDA compiler detected")
325 # elif(GLM_COMPILER & GLM_COMPILER_VC)
326 # pragma message("GLM: Visual C++ compiler detected")
327 # elif(GLM_COMPILER & GLM_COMPILER_CLANG)
328 # pragma message("GLM: Clang compiler detected")
329 # elif(GLM_COMPILER & GLM_COMPILER_LLVM_GCC)
330 # pragma message("GLM: LLVM GCC compiler detected")
331 # elif(GLM_COMPILER & GLM_COMPILER_INTEL)
332 # pragma message("GLM: Intel Compiler detected")
333 # elif(GLM_COMPILER & GLM_COMPILER_GCC)
334 # if(GLM_COMPILER == GLM_COMPILER_GCC_LLVM)
335 # pragma message("GLM: LLVM GCC compiler detected")
336 # elif(GLM_COMPILER == GLM_COMPILER_GCC_CLANG)
337 # pragma message("GLM: CLANG compiler detected")
338 # else
339 # pragma message("GLM: GCC compiler detected")
340 # endif
341 # elif(GLM_COMPILER & GLM_COMPILER_BC)
342 # pragma message("GLM: Borland compiler detected but not supported")
343 # elif(GLM_COMPILER & GLM_COMPILER_CODEWARRIOR)
344 # pragma message("GLM: Codewarrior compiler detected but not supported")
345 # else
346 # pragma message("GLM: Compiler not detected")
347 # endif
348 #endif//GLM_MESSAGE
349 
351 // Build model //
352 
353 #if(defined(__arch64__) || defined(__LP64__) || defined(_M_X64) || defined(__ppc64__) || defined(__x86_64__))
354 # define GLM_MODEL GLM_MODEL_64
355 #elif(defined(__i386__) || defined(__ppc__))
356 # define GLM_MODEL GLM_MODEL_32
357 #else
358 # define GLM_MODEL GLM_MODEL_32
359 #endif//
360 
361 #if(!defined(GLM_MODEL) && GLM_COMPILER != 0)
362 # error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
363 #endif//GLM_MODEL
364 
365 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_MODEL_DISPLAYED))
366 # define GLM_MESSAGE_MODEL_DISPLAYED
367 # if(GLM_MODEL == GLM_MODEL_64)
368 # pragma message("GLM: 64 bits model")
369 # elif(GLM_MODEL == GLM_MODEL_32)
370 # pragma message("GLM: 32 bits model")
371 # endif//GLM_MODEL
372 #endif//GLM_MESSAGE
373 
375 // C++ Version //
376 
377 // User defines: GLM_FORCE_CXX98
378 
379 #define GLM_LANG_CXX_FLAG (1 << 0)
380 #define GLM_LANG_CXX98_FLAG (1 << 1)
381 #define GLM_LANG_CXX03_FLAG (1 << 2)
382 #define GLM_LANG_CXX0X_FLAG (1 << 3)
383 #define GLM_LANG_CXX11_FLAG (1 << 4)
384 #define GLM_LANG_CXX1Y_FLAG (1 << 5)
385 #define GLM_LANG_CXXMS_FLAG (1 << 6)
386 #define GLM_LANG_CXXGNU_FLAG (1 << 7)
387 
388 #define GLM_LANG_CXX GLM_LANG_CXX_FLAG
389 #define GLM_LANG_CXX98 (GLM_LANG_CXX | GLM_LANG_CXX98_FLAG)
390 #define GLM_LANG_CXX03 (GLM_LANG_CXX98 | GLM_LANG_CXX03_FLAG)
391 #define GLM_LANG_CXX0X (GLM_LANG_CXX03 | GLM_LANG_CXX0X_FLAG)
392 #define GLM_LANG_CXX11 (GLM_LANG_CXX0X | GLM_LANG_CXX11_FLAG)
393 #define GLM_LANG_CXX1Y (GLM_LANG_CXX11 | GLM_LANG_CXX1Y_FLAG)
394 #define GLM_LANG_CXXMS GLM_LANG_CXXMS_FLAG
395 #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG
396 
397 #if(defined(GLM_FORCE_CXX1Y))
398 # define GLM_LANG GLM_LANG_CXX1Y
399 #elif(defined(GLM_FORCE_CXX11))
400 # define GLM_LANG GLM_LANG_CXX11
401 #elif(defined(GLM_FORCE_CXX03))
402 # define GLM_LANG GLM_LANG_CXX03
403 #elif(defined(GLM_FORCE_CXX98))
404 # define GLM_LANG GLM_LANG_CXX98
405 #else
406 # if(__cplusplus >= 201103L)
407 # define GLM_LANG GLM_LANG_CXX11
408 # elif((GLM_COMPILER & GLM_COMPILER_CLANG) == GLM_COMPILER_CLANG)
409 # if(GLM_PLATFORM == GLM_PLATFORM_APPLE)
410 # define GLM_DETAIL_MAJOR 1
411 # else
412 # define GLM_DETAIL_MAJOR 0
413 # endif
414 # if(__clang_major__ < (2 + GLM_DETAIL_MAJOR))
415 # define GLM_LANG GLM_LANG_CXX
416 # elif(__has_feature(cxx_auto_type))
417 # define GLM_LANG GLM_LANG_CXX0X
418 # else
419 # define GLM_LANG GLM_LANG_CXX98
420 # endif
421 # elif((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC)
422 # if defined(__GXX_EXPERIMENTAL_CXX0X__)
423 # define GLM_LANG GLM_LANG_CXX0X
424 # else
425 # define GLM_LANG GLM_LANG_CXX98
426 # endif
427 # elif(GLM_COMPILER & GLM_COMPILER_VC)
428 # if(defined(_MSC_EXTENSIONS))
429 # if(GLM_COMPILER >= GLM_COMPILER_VC10)
430 # define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
431 # else
432 # define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
433 # endif
434 # else
435 # if(GLM_COMPILER >= GLM_COMPILER_VC10)
436 # define GLM_LANG GLM_LANG_CXX0X
437 # else
438 # define GLM_LANG GLM_LANG_CXX98
439 # endif
440 # endif
441 # elif(GLM_COMPILER & GLM_COMPILER_INTEL)
442 # if(defined(_MSC_EXTENSIONS))
443 # if(GLM_COMPILER >= GLM_COMPILER_INTEL13_0)
444 # define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
445 # else
446 # define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
447 # endif
448 # else
449 # if(GLM_COMPILER >= GLM_COMPILER_INTEL13_0)
450 # define GLM_LANG (GLM_LANG_CXX0X)
451 # else
452 # define GLM_LANG (GLM_LANG_CXX98)
453 # endif
454 # endif
455 # elif(__cplusplus >= 199711L)
456 # define GLM_LANG GLM_LANG_CXX98
457 # else
458 # define GLM_LANG GLM_LANG_CXX
459 # endif
460 #endif
461 
462 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED))
463 # define GLM_MESSAGE_LANG_DISPLAYED
464 # if(GLM_LANG & GLM_LANG_CXXGNU_FLAG)
465 # pragma message("GLM: C++ with language extensions")
466 # elif(GLM_LANG & GLM_LANG_CXXMS_FLAG)
467 # pragma message("GLM: C++ with language extensions")
468 # elif(GLM_LANG & GLM_LANG_CXX11_FLAG)
469 # pragma message("GLM: C++11")
470 # elif(GLM_LANG & GLM_LANG_CXX0X_FLAG)
471 # pragma message("GLM: C++0x")
472 # elif(GLM_LANG & GLM_LANG_CXX03_FLAG)
473 # pragma message("GLM: C++03")
474 # elif(GLM_LANG & GLM_LANG_CXX98_FLAG)
475 # pragma message("GLM: C++98")
476 # else
477 # pragma message("GLM: C++ language undetected")
478 # endif//GLM_MODEL
479 # pragma message("GLM: #define GLM_FORCE_CXX98, GLM_FORCE_CXX03, GLM_LANG_CXX11 or GLM_FORCE_CXX1Y to force using a specific version of the C++ language")
480 #endif//GLM_MESSAGE
481 
483 // Has of C++ features
484 
485 #ifndef __has_feature
486 # define __has_feature(x) 0 // Compatibility with non-clang compilers.
487 #endif
488 #ifndef __has_extension
489 # define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
490 #endif
491 
492 // http://clang.llvm.org/cxx_status.html
493 // http://gcc.gnu.org/projects/cxx0x.html
494 // http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
495 
496 // N1720
497 #define GLM_HAS_STATIC_ASSERT ( \
498  (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
499  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC10)) || \
500  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \
501  __has_feature(cxx_static_assert))
502 
503 // N1988
504 #define GLM_HAS_EXTENDED_INTEGER_TYPE ( \
505  (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
506  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC11)) || \
507  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \
508  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG29)))
509 
510 // N2235
511 #define GLM_HAS_CONSTEXPR ( \
512  (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
513  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \
514  __has_feature(cxx_constexpr))
515 
516 // N2672
517 #define GLM_HAS_INITIALIZER_LISTS ( \
518  (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
519  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12))) || \
520  ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \
521  __has_feature(cxx_generalized_initializers))
522 
523 // OpenMP
524 #ifdef _OPENMP
525 # if(GLM_COMPILER & GLM_COMPILER_GCC)
526 # if(GLM_COMPILER > GLM_COMPILER_GCC47)
527 # define GLM_HAS_OPENMP 31
528 # elif(GLM_COMPILER > GLM_COMPILER_GCC44)
529 # define GLM_HAS_OPENMP 30
530 # elif(GLM_COMPILER > GLM_COMPILER_GCC42)
531 # define GLM_HAS_OPENMP 25
532 # endif
533 # endif//(GLM_COMPILER & GLM_COMPILER_GCC)
534 
535 # if(GLM_COMPILER & GLM_COMPILER_VC)
536 # if(GLM_COMPILER > GLM_COMPILER_VC8)
537 # define GLM_HAS_OPENMP 20
538 # endif
539 # endif//(GLM_COMPILER & GLM_COMPILER_GCC)
540 #endif
541 
542 // Not standard
543 #define GLM_HAS_ANONYMOUS_UNION (GLM_LANG & GLM_LANG_CXXMS_FLAG)
544 
546 // Platform
547 
548 // User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_AVX
549 
550 #define GLM_ARCH_PURE 0x0000
551 #define GLM_ARCH_SSE2 0x0001
552 #define GLM_ARCH_SSE3 0x0002// | GLM_ARCH_SSE2
553 #define GLM_ARCH_SSE4 0x0004// | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
554 #define GLM_ARCH_AVX 0x0008// | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
555 #define GLM_ARCH_AVX2 0x0010// | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2
556 
557 #if(defined(GLM_FORCE_PURE))
558 # define GLM_ARCH GLM_ARCH_PURE
559 #elif(defined(GLM_FORCE_AVX2))
560 # define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
561 #elif(defined(GLM_FORCE_AVX))
562 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
563 #elif(defined(GLM_FORCE_SSE4))
564 # define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
565 #elif(defined(GLM_FORCE_SSE3))
566 # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
567 #elif(defined(GLM_FORCE_SSE2))
568 # define GLM_ARCH (GLM_ARCH_SSE2)
569 #elif((GLM_COMPILER & GLM_COMPILER_VC) && (defined(_M_IX86) || defined(_M_X64)))
570 # if(GLM_PLATFORM == GLM_PLATFORM_WINCE)
571 # define GLM_ARCH GLM_ARCH_PURE
572 # elif(defined(_M_CEE_PURE))
573 # define GLM_ARCH GLM_ARCH_PURE
574 /* TODO: Explore auto detection of instruction set support
575 # elif(defined(_M_IX86_FP))
576 # if(_M_IX86_FP >= 3)
577 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
578 # elif(_M_IX86_FP >= 2)
579 # define GLM_ARCH (GLM_ARCH_SSE2)
580 # else
581 # define GLM_ARCH GLM_ARCH_PURE
582 # endif
583 */
584 # elif(GLM_COMPILER >= GLM_COMPILER_VC11)
585 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
586 # elif(GLM_COMPILER >= GLM_COMPILER_VC10)
587 # if(_MSC_FULL_VER >= 160031118) //160031118: VC2010 SP1 beta full version
588 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)//GLM_ARCH_AVX (Require SP1)
589 # else
590 # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
591 # endif
592 # elif(GLM_COMPILER >= GLM_COMPILER_VC9)
593 # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
594 # elif(GLM_COMPILER >= GLM_COMPILER_VC8)
595 # define GLM_ARCH GLM_ARCH_SSE2
596 # else
597 # define GLM_ARCH GLM_ARCH_PURE
598 # endif
599 #elif((GLM_PLATFORM & GLM_PLATFORM_APPLE) && (GLM_COMPILER & GLM_COMPILER_GCC))
600 # define GLM_ARCH GLM_ARCH_PURE
601 #elif(((GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__))) || (GLM_COMPILER & GLM_COMPILER_LLVM_GCC))
602 # define GLM_ARCH (GLM_ARCH_PURE \
603 | (defined(__AVX2__) ? GLM_ARCH_AVX2 : 0) \
604 | (defined(__AVX__) ? GLM_ARCH_AVX : 0) \
605 | (defined(__SSE4__) ? GLM_ARCH_SSE4 : 0) \
606 | (defined(__SSE3__) ? GLM_ARCH_SSE3 : 0) \
607 | (defined(__SSE2__) ? GLM_ARCH_SSE2 : 0))
608 #else
609 # define GLM_ARCH GLM_ARCH_PURE
610 #endif
611 
612 // With MinGW-W64, including intrinsic headers before intrin.h will produce some errors. The problem is
613 // that windows.h (and maybe other headers) will silently include intrin.h, which of course causes problems.
614 // To fix, we just explicitly include intrin.h here.
615 #if defined(__MINGW32__) && (GLM_ARCH != GLM_ARCH_PURE)
616 # include <intrin.h>
617 #endif
618 
619 //#if(GLM_ARCH != GLM_ARCH_PURE)
620 #if(GLM_ARCH & GLM_ARCH_AVX2)
621 # include <immintrin.h>
622 #endif//GLM_ARCH
623 #if(GLM_ARCH & GLM_ARCH_AVX)
624 # include <immintrin.h>
625 #endif//GLM_ARCH
626 #if(GLM_ARCH & GLM_ARCH_SSE4)
627 # include <smmintrin.h>
628 #endif//GLM_ARCH
629 #if(GLM_ARCH & GLM_ARCH_SSE3)
630 # include <pmmintrin.h>
631 #endif//GLM_ARCH
632 #if(GLM_ARCH & GLM_ARCH_SSE2)
633 # include <emmintrin.h>
634 # if(GLM_COMPILER == GLM_COMPILER_VC8) // VC8 is missing some intrinsics, workaround
635  inline float _mm_cvtss_f32(__m128 A) { return A.m128_f32[0]; }
636  inline __m128 _mm_castpd_ps(__m128d PD) { union { __m128 ps; __m128d pd; } c; c.pd = PD; return c.ps; }
637  inline __m128d _mm_castps_pd(__m128 PS) { union { __m128 ps; __m128d pd; } c; c.ps = PS; return c.pd; }
638  inline __m128i _mm_castps_si128(__m128 PS) { union { __m128 ps; __m128i pi; } c; c.ps = PS; return c.pi; }
639  inline __m128 _mm_castsi128_ps(__m128i PI) { union { __m128 ps; __m128i pi; } c; c.pi = PI; return c.ps; }
640 # endif
641 #endif//GLM_ARCH
642 //#endif//(GLM_ARCH != GLM_ARCH_PURE)
643 
644 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_ARCH_DISPLAYED))
645 # define GLM_MESSAGE_ARCH_DISPLAYED
646 # if(GLM_ARCH == GLM_ARCH_PURE)
647 # pragma message("GLM: Platform independent")
648 # elif(GLM_ARCH & GLM_ARCH_SSE2)
649 # pragma message("GLM: SSE2 instruction set")
650 # elif(GLM_ARCH & GLM_ARCH_SSE3)
651 # pragma message("GLM: SSE3 instruction set")
652 # elif(GLM_ARCH & GLM_ARCH_SSE4)
653 # pragma message("GLM: SSE4 instruction set")
654 # elif(GLM_ARCH & GLM_ARCH_AVX)
655 # pragma message("GLM: AVX instruction set")
656 # elif(GLM_ARCH & GLM_ARCH_AVX2)
657 # pragma message("GLM: AVX2 instruction set")
658 # endif//GLM_ARCH
659 # pragma message("GLM: #define GLM_FORCE_PURE to avoid using platform specific instruction sets")
660 #endif//GLM_MESSAGE
661 
663 // Radians
664 
665 //#define GLM_FORCE_RADIANS
666 
668 // Static assert
669 
670 #if GLM_HAS_STATIC_ASSERT
671 # define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
672 #elif(defined(BOOST_STATIC_ASSERT))
673 # define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)
674 #elif(GLM_COMPILER & GLM_COMPILER_VC)
675 # define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
676 #else
677 # define GLM_STATIC_ASSERT(x, message)
678 # define GLM_STATIC_ASSERT_NULL
679 #endif//GLM_LANG
680 
682 // Qualifiers
683 
684 // User defines: GLM_FORCE_INLINE GLM_FORCE_CUDA
685 
686 #if(defined(GLM_FORCE_CUDA) || (GLM_COMPILER & GLM_COMPILER_CUDA))
687 # define GLM_CUDA_FUNC_DEF __device__ __host__
688 # define GLM_CUDA_FUNC_DECL __device__ __host__
689 #else
690 # define GLM_CUDA_FUNC_DEF
691 # define GLM_CUDA_FUNC_DECL
692 #endif
693 
694 #if GLM_COMPILER & GLM_COMPILER_GCC
695 # define GLM_VAR_USED __attribute__ ((unused))
696 #else
697 # define GLM_VAR_USED
698 #endif
699 
700 #if(defined(GLM_FORCE_INLINE))
701 # if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC8))
702 # define GLM_INLINE __forceinline
703 # elif((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC34))
704 # define GLM_INLINE __attribute__((always_inline)) inline
705 # elif(GLM_COMPILER & GLM_COMPILER_CLANG)
706 # define GLM_INLINE __attribute__((always_inline))
707 # else
708 # define GLM_INLINE inline
709 # endif//GLM_COMPILER
710 #else
711 # define GLM_INLINE inline
712 #endif//defined(GLM_FORCE_INLINE)
713 
714 #define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL
715 #define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE
716 
718 // Swizzle operators
719 
720 // User defines: GLM_SWIZZLE
721 
722 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED))
723 # define GLM_MESSAGE_SWIZZLE_DISPLAYED
724 # if defined(GLM_SWIZZLE)
725 # pragma message("GLM: Swizzling operators enabled")
726 # else
727 # pragma message("GLM: Swizzling operators disabled, #define GLM_SWIZZLE to enable swizzle operators")
728 # endif
729 #endif//GLM_MESSAGE
730 
732 // Length type
733 
734 // User defines: GLM_FORCE_SIZE_T_LENGTH
735 
736 namespace glm
737 {
738 #if defined(GLM_FORCE_SIZE_T_LENGTH)
739  typedef std::size_t length_t;
740 #else
741  typedef int length_t;
742 #endif
743 }//namespace glm
744 
745 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_FORCE_SIZE_T_LENGTH))
746 # define GLM_MESSAGE_FORCE_SIZE_T_LENGTH
747 # if defined(GLM_FORCE_SIZE_T_LENGTH)
748 # pragma message("GLM: .length() returns glm::length_t, a typedef of std::size_t")
749 # else
750 # pragma message("GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification")
751 # pragma message("GLM: #define GLM_FORCE_SIZE_T_LENGTH for .length() to return a std::size_t")
752 # endif
753 #endif//GLM_MESSAGE
754 
756 // Qualifiers
757 
758 #if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC8))
759 # define GLM_DEPRECATED __declspec(deprecated)
760 # define GLM_ALIGN(x) __declspec(align(x))
761 # define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
762 # define GLM_RESTRICT __declspec(restrict)
763 # define GLM_RESTRICT_VAR __restrict
764 #elif(GLM_COMPILER & GLM_COMPILER_INTEL)
765 # define GLM_DEPRECATED
766 # define GLM_ALIGN(x) __declspec(align(x))
767 # define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
768 # define GLM_RESTRICT
769 # define GLM_RESTRICT_VAR __restrict
770 #elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG))
771 # define GLM_DEPRECATED __attribute__((__deprecated__))
772 # define GLM_ALIGN(x) __attribute__((aligned(x)))
773 # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
774 # define GLM_RESTRICT __restrict__
775 # define GLM_RESTRICT_VAR __restrict__
776 #else
777 # define GLM_DEPRECATED
778 # define GLM_ALIGN
779 # define GLM_ALIGNED_STRUCT(x)
780 # define GLM_RESTRICT
781 # define GLM_RESTRICT_VAR
782 #endif//GLM_COMPILER
783 
784 #if GLM_HAS_CONSTEXPR
785 # define GLM_CONSTEXPR constexpr
786 #else
787 # define GLM_CONSTEXPR
788 #endif
789 
790 #endif//GLM_SETUP_INCLUDED
GLM_FUNC_DECL genType pi()
Return the pi constant.