summaryrefslogtreecommitdiffstats
path: root/prelude/slang-cpp-prelude.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-06-18 14:46:14 -0400
committerjsmall-nvidia <jsmall@nvidia.com>2020-06-18 14:46:14 -0400
commite2d21026d115dc61296b47dcc990534f1844bc7f (patch)
tree2839c02439c37fb568e46aab62f163893040b56c /prelude/slang-cpp-prelude.h
parent48da3ed09c84cd53f24b1f3628402f0bbc92e540 (diff)
Try using cmath or math.h depending on compiler to avoid issues around isinf etc.
Diffstat (limited to 'prelude/slang-cpp-prelude.h')
-rw-r--r--prelude/slang-cpp-prelude.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/prelude/slang-cpp-prelude.h b/prelude/slang-cpp-prelude.h
index 4a07674d1..d476676ed 100644
--- a/prelude/slang-cpp-prelude.h
+++ b/prelude/slang-cpp-prelude.h
@@ -3,7 +3,18 @@
#include "../slang.h"
-#include <cmath>
+// Because the signiture of isnan, isfinite, and is isinf changed in C++, we use the macro
+// to use the version in the std namespace.
+// https://stackoverflow.com/questions/39130040/cmath-hides-isnan-in-math-h-in-c14-c11
+
+#if SLANG_GCC_FAMILY && __GNUC__ < 6
+# include <cmath>
+# define SLANG_PRELUDE_STD std::
+#else
+# include <math.h>
+# define SLANG_PRELUDE_STD
+#endif
+
#include <assert.h>
#include <stdlib.h>