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 >= 202002L)
29 # define IMATH_CPLUSPLUS_VERSION 20
30 #elif (__cplusplus >= 201703L)
31 # define IMATH_CPLUSPLUS_VERSION 17
32 #elif (__cplusplus >= 201402L) || (defined(_MSC_VER) && _MSC_VER >= 1914)
33 # define IMATH_CPLUSPLUS_VERSION 14
34 #elif (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900)
35 # define IMATH_CPLUSPLUS_VERSION 11
36 #else
37 # error "This version of Imath is meant to work only with C++11 and above"
38 #endif
39 
40 
41 //
42 // Constexpr C++14 conditional definition
43 //
44 #if (IMATH_CPLUSPLUS_VERSION >= 14)
45  #define IMATH_CONSTEXPR14 constexpr
46 #else
47  #define IMATH_CONSTEXPR14 /* can not be constexpr before c++14 */
48 #endif
49 
50 #endif // __cplusplus
51 
52 #ifndef M_PI
53 # define M_PI 3.14159265358979323846
54 #endif
55 
56 #ifndef M_PI_2
57 # define M_PI_2 1.57079632679489661923 // pi/2
58 #endif
59 
60 //-----------------------------------------------------------------------------
61 //
62 // Some, but not all, C++ compilers support the C99 restrict
63 // keyword or some variant of it, for example, __restrict.
64 //
65 //-----------------------------------------------------------------------------
66 
67 #if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) || defined(__INTEL_COMPILER)
68 # define IMATH_RESTRICT __restrict
69 #else
70 # define IMATH_RESTRICT
71 #endif
72 
73 #ifdef __cplusplus
74 
75 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
76 
77 #endif // __cplusplus
78 
79 /// @endcond
80 
81 #endif // INCLUDED_IMATHPLATFORM_H