[英]How to resolve "fpclassify': ambiguous call to overloaded function
[英]"fpclassify': ambiguous call to overloaded function
我有一個與此非常相似的問題: 如何解決“fpclassify”:對重載 function 的模糊調用
我有一個包含大約 100 個 cpp 文件和 100 個頭文件的大型項目,它們使用 GNU GCC 編譯器在代碼塊中運行良好,但我想將該項目遷移到 VS19。 除了一個錯誤之外,它似乎工作正常: "fpclassify': ambiguous call to overloaded function
VS19 中的錯誤列表告訴我它位於corecrt_math.h
第 415 行的返回值上:
template <class _Ty>
_Check_return_ inline bool isnan(_In_ _Ty _X) throw()
{
return fpclassify(_X) == FP_NAN;
}
查看我的代碼時,我發現我在 13 個文件、24 個位置(錯誤列表根本不涉及這些位置)中使用了std::isna
。 但是,與我上面鏈接的問題不同,我沒有看到我檢查int
是否在任何地方都是na
。 相反,我有這樣的案例:
if (std::isnan(static_cast<double> (min)) && std::isnan(static_cast<double> (max)))
simulation_error("Error: No limits");
其中min
和max
定義為const double & min = NAN
和const double & max = NAN
( min
和max
在構造函數中設置)。
您對如何找到錯誤以及如何解決有任何想法嗎? 我昨天嘗試了很多小時 - 沒有任何成功。
編輯:
完整的錯誤信息如下:
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> ]
其中指的是:
std::vector<double> stoprule_rel;,
if (!(std::isnan(static_cast<double> (stoprule_rel[i])
像fpclassify': ambiguous call to overloaded function
這樣的錯誤信息總是伴隨着notes 。 例如,對於一個簡單的程序
#include <cmath>
int main() {
std::isnan(5);
}
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 ]
從這些注釋中我們可以推斷出_Ty
是int
並且在我們的源代碼的第 3 行調用了std::nan
。 查看完整的編譯器 output 進行編譯,它會告訴您代碼中觸發錯誤的確切位置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.