More than one instance of overloaded function

2019-09-01 07:36发布

问题:

I am trying to compile a library that uses CUDA, on an Ubuntu system using CUDA 8.0 and clang 3.8. The library includes Eigen headers in several *.cu files, which apparently includes the cmath header, causing an ambiguity in the CUDA headers.

/usr/local/cuda-8.0/include/cuda_fp16.h(3068): error: more than one instance of overloaded function "isinf" matches the argument list:
            function "std::isinf(float)"
            function "isinf(float)"
            argument types are: (float)

CUDA defines its own __device__ ​ __RETURN_TYPE isinf ( float a ), and I would expect that std::isinf would have to be called explicitly rather than create a conflict.

Any leads on this would be much appreciated.

回答1:

As I recall, this is actually a Clang problem. Compiling in C++11 mode with Clang 3.8 and gcc 6 standard library headers will trigger the problem. If you switch to a supported gcc 5 version, or don't specify C++11 support, the problem will disappear.