简体   繁体   English

“fpclassify”:对重载 function 的模糊调用

[英]"fpclassify': ambiguous call to overloaded function

I have a very similar problem to this one: How to resolve "fpclassify': ambiguous call to overloaded function我有一个与此非常相似的问题: 如何解决“fpclassify”:对重载 function 的模糊调用

I have a large project with about 100 cpp-files and 100 header-files that work fine in Codeblocks using GNU GCC compiler, but I want to migrate the project to VS19.我有一个包含大约 100 个 cpp 文件和 100 个头文件的大型项目,它们使用 GNU GCC 编译器在代码块中运行良好,但我想将该项目迁移到 VS19。 It seems to work fine except for one error: "fpclassify': ambiguous call to overloaded function除了一个错误之外,它似乎工作正常: "fpclassify': ambiguous call to overloaded function

The error list in VS19 tells me it is located in corecrt_math.h on a return value at line 415: VS19 中的错误列表告诉我它位于corecrt_math.h第 415 行的返回值上:

template <class _Ty>
_Check_return_ inline bool isnan(_In_ _Ty _X) throw()
{
    return fpclassify(_X) == FP_NAN;
}

When looking into my code I see that I use std::isna in 13 files, 24 locations (the error list does not refer to these places at all).查看我的代码时,我发现我在 13 个文件、24 个位置(错误列表根本不涉及这些位置)中使用了std::isna However, unlike the problem that I linked to above, I do not see that I check if an int is na anywhere.但是,与我上面链接的问题不同,我没有看到我检查int是否在任何地方都是na Instead I have cases like this:相反,我有这样的案例:

if (std::isnan(static_cast<double> (min)) && std::isnan(static_cast<double> (max)))
    simulation_error("Error: No limits");

Where min and max are defined as const double & min = NAN and const double & max = NAN ( min and max are set in the constructor).其中minmax定义为const double & min = NANconst double & max = NANminmax在构造函数中设置)。

Do you have any idea on how to find the error and how to solve it?您对如何找到错误以及如何解决有任何想法吗? I tried many hours yesterday - without any success.我昨天尝试了很多小时 - 没有任何成功。

Edit:编辑:

Full error message below:完整的错误信息如下:

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt_math.h(415,1): error C2668: 'fpclassify': ambiguous call to overloaded function
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt_math.h(300,31): message : could be 'int fpclassify(long double) noexcept'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt_math.h(295,31): message : or       'int fpclassify(double) noexcept'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt_math.h(290,31): message : or       'int fpclassify(float) noexcept'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt_math.h(415,1): message : while trying to match the argument list '(_Ty)'
1>        with
1>        [
1>            _Ty=bool
1>        ]
1>C:\Users\Name\Documents\C++\Project name\Project name\src\module.cpp(668): message : see reference to function template instantiation 'bool isnan<bool>(_Ty) noexcept' being compiled
1>        with
1>        [
1>            _Ty=bool
1>        ]

Which refers to:其中指的是:

std::vector<double> stoprule_rel;,

if (!(std::isnan(static_cast<double> (stoprule_rel[i])

The error message like fpclassify': ambiguous call to overloaded function is always accompanied by notes .fpclassify': ambiguous call to overloaded function这样的错误信息总是伴随着notes For example, for a simple program例如,对于一个简单的程序

#include <cmath>
int main() {
    std::isnan(5);
}

VS complains : VS抱怨

corecrt_math.h(415): error C2668: 'fpclassify': ambiguous call to overloaded function
corecrt_math.h(300): note: could be 'int fpclassify(long double) throw()'
corecrt_math.h(295): note: or       'int fpclassify(double) throw()'
corecrt_math.h(290): note: or       'int fpclassify(float) throw()'
corecrt_math.h(415): note: while trying to match the argument list '(_Ty)'
        with [ _Ty=int ]
<source>(3): note: see reference to function template instantiation 'bool isnan<int>(_Ty) throw()' being compiled
        with [ _Ty=int ]

From these notes we can infer that _Ty is int and that std::nan was called on the line 3 of our source code.从这些注释中我们可以推断出_Tyint并且在我们的源代码的第 3 行调用了std::nan Take a look at the full compiler output for your compilation, it will tell you the exact place in your code where the error is triggered.查看完整的编译器 output 进行编译,它会告诉您代码中触发错误的确切位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM