HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImathPlatform.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright Contributors to the OpenEXR Project.
4 //
5 
6 //
7 // This file contains functions and constants which aren't
8 // provided by the system libraries, compilers, or includes on
9 // certain platforms.
10 //
11 
12 #ifndef INCLUDED_IMATHPLATFORM_H
13 #define INCLUDED_IMATHPLATFORM_H
14 
15 /// @cond Doxygen_Suppress
16 
17 #include <math.h>
18 
19 #include "ImathNamespace.h"
20 
21 #ifdef __cplusplus
22 
23 IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
24 
25 //
26 // Helpful macros for checking which C++ standard we are compiling with.
27 //
28 # if (__cplusplus >= 202302L)
29 # define IMATH_CPLUSPLUS_VERSION 23
30 # elif (__cplusplus >= 202002L)
31 # define IMATH_CPLUSPLUS_VERSION 20
32 # elif (__cplusplus >= 201703L)
33 # define IMATH_CPLUSPLUS_VERSION 17
34 # elif (__cplusplus >= 201402L) || (defined(_MSC_VER) && _MSC_VER >= 1914)
35 # define IMATH_CPLUSPLUS_VERSION 14
36 # elif (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900)
37 # define IMATH_CPLUSPLUS_VERSION 11
38 # else
39 # error \
40  "This version of Imath is meant to work only with C++11 and above"
41 # endif
42 
43 //
44 // Constexpr C++14 conditional definition
45 //
46 # if (IMATH_CPLUSPLUS_VERSION >= 14)
47 # define IMATH_CONSTEXPR14 constexpr
48 # else
49 # define IMATH_CONSTEXPR14 /* can not be constexpr before c++14 */
50 # endif
51 
52 #endif // __cplusplus
53 
54 #ifndef M_PI
55 # define M_PI 3.14159265358979323846
56 #endif
57 
58 #ifndef M_PI_2
59 # define M_PI_2 1.57079632679489661923 // pi/2
60 #endif
61 
62 //-----------------------------------------------------------------------------
63 //
64 // Some, but not all, C++ compilers support the C99 restrict
65 // keyword or some variant of it, for example, __restrict.
66 //
67 //-----------------------------------------------------------------------------
68 
69 #if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) || \
70  defined(__INTEL_COMPILER)
71 # define IMATH_RESTRICT __restrict
72 #else
73 # define IMATH_RESTRICT
74 #endif
75 
76 #ifdef __cplusplus
77 
78 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
79 
80 #endif // __cplusplus
81 
82 /// @endcond
83 
84 #endif // INCLUDED_IMATHPLATFORM_H