KhronosGroup / OpenCOLLADA

652 stars 251 forks source link

error: no member named 'isnan' in namespace 'std'; did you mean simply 'isnan'? #594

Closed shoeffner closed 5 years ago

shoeffner commented 5 years ago

When compiling COLLADA2GLTF, I receive the error "no member named 'isnan' in namespace 'std'", when it compiles OpenCOLLADA as a dependency. The error occurs for COLLADA2GLTF's master and v2.1.4. I also moved OpenCOLLADA from 619d9421 to the current master, but the error persists, thus I assume it's an OpenCOLLADA issue.

OS: macOS 10.14 compiler: AppleClang 10.0.0.10001145

Relevant log:

/Users/shoeffner/Projects/COLLADA2GLTF/dependencies/OpenCOLLADA/OpenCOLLADA/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp:1559:16: error: no member named 'isnan' in namespace 'std'; did you mean simply 'isnan'?
        return std::isnan(value);
               ^~~~~~~~~~
               isnan
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:513:1: note: 'isnan' declared here
isnan(_A1) _NOEXCEPT
^
/Users/shoeffner/Projects/COLLADA2GLTF/dependencies/OpenCOLLADA/OpenCOLLADA/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp:1559:21: error: call to function 'isnan' that is neither visible in the template definition nor found by argument-dependent lookup
        return std::isnan(value);
                    ^
/Users/shoeffner/Projects/COLLADA2GLTF/dependencies/OpenCOLLADA/OpenCOLLADA/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp:1591:16: note: in instantiation of function template specialization 'GeneratedSaxParser::Utils::isNaN<float>' requested here
        return isNaN<float>( value );
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:505:1: note: 'isnan' should be declared prior to the call site
isnan(_A1 __lcpp_x) _NOEXCEPT
^
/Users/shoeffner/Projects/COLLADA2GLTF/dependencies/OpenCOLLADA/OpenCOLLADA/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp:1559:21: error: call to function 'isnan' that is neither visible in the template definition nor found by argument-dependent lookup
        return std::isnan(value);
                    ^
/Users/shoeffner/Projects/COLLADA2GLTF/dependencies/OpenCOLLADA/OpenCOLLADA/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp:1597:16: note: in instantiation of function template specialization 'GeneratedSaxParser::Utils::isNaN<double>' requested here
        return isNaN<double>( value );
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:505:1: note: 'isnan' should be declared prior to the call site
isnan(_A1 __lcpp_x) _NOEXCEPT
^
3 errors generated.
make[2]: *** [dependencies/OpenCOLLADA/modules/COLLADASaxFrameworkLoader/GeneratedSaxParser/CMakeFiles/GeneratedSaxParser.dir/__/__/__/OpenCOLLADA/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp.o] Error 1
make[1]: *** [dependencies/OpenCOLLADA/modules/COLLADASaxFrameworkLoader/GeneratedSaxParser/CMakeFiles/GeneratedSaxParser.dir/all] Error 2
make: *** [all] Error 2

It seems there is just a missing import for macOS, so here is a patch which results in a successful compilation:

From b465514ac8c711224967f7b78dfbea83dc4a76bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20H=C3=B6ffner?= <info@sebastian-hoeffner.de>
Date: Fri, 12 Oct 2018 13:34:16 +0200
Subject: [PATCH] Adding cmath include to GeneratedSaxParserUtils.

Resolves "no member named 'isnan' in namespace 'std'" on macOS
using clang 10.0.0.10001145.
---
 GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp b/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp
index 1f9a3eef..dd6f5c59 100644
--- a/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp
+++ b/GeneratedSaxParser/src/GeneratedSaxParserUtils.cpp
@@ -10,6 +10,7 @@

 #include "GeneratedSaxParserUtils.h"
 #include <math.h>
+#include <cmath>
 #include <memory>
 #include <string.h>
 #include <limits>
-- 
2.19.0

If this is the correct solution, I can create a PR or you can use the patch here to fix it. Let me know if you need any other information!

shoeffner commented 5 years ago

Oh, now that I fixed it, I see that #576 deals with the same issue (although differently). I didn't find it when I searched for "isnan" in the issues... I guess I should also search for PRs next time. So if #576 resolves the issue and you don't want the extra include statement, feel free to close this PR!

shoeffner commented 5 years ago

Closed due to no activity and duplication in #576

eriadam commented 4 years ago

@shoeffner Hello, it seems neither this, nor the #576 got merged after all, so the issue still exists. The #include <cmath> did solve the problem for me.