64位无符号int到float转换的未定义参考错误

问题描述

get_float64()中的此行显示错误

“未定义对__aeabi_ul2d的引用”

我认为类似的get_float32()不会出现这种问题。 get_float64()函数在这里可能有什么问题?

fvalue = static_cast<double>(value);  //Showing up error while compiling for GCC..


float get_float32()
{
    float fvalue(0.0f);
    uInt32 value = retrieve_uInt32();//Return 32bit Unsigned int value
    fvalue = static_cast<Float32>(value); //No error here for float32
    return fvalue;
}

double get_float64()
{
    double fvalue = static_cast<double>(0.0f);
    uInt64 value = retrieve_uInt64(); //Return 64bit Unsigned int value
    fvalue = static_cast<double>(value);  //Showing up error while compiling for GCC.. undefined reference to `__aeabi_ul2d
    return fvalue;
}

我不想在这里使用reinterpret_cast,这会引发-Wstrict-aliasing错误。使用下面的代码使用-O2选项发出警告

warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
fvalue = *reinterpret_cast<Float64*>(&value);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)