【问题标题】:Qt build fails due to missing std::isnan in Visual Studio 2012由于 Visual Studio 2012 中缺少 std::isnan,Qt 构建失败
【发布时间】:2014-01-22 16:44:50
【问题描述】:

我正在尝试使用 Visual Studio 2012 从源代码构建 Qt 5.2.0。编译以下文件时失败:

/qtdeclarative/src/qml/jsruntime/qv4value_p.h

出现以下错误:

191: error C2039: _isnan: is not a member of std

第 191 行包含以下内容:

return doubleValue() && !std::isnan(doubleValue());

According to cppreference, std::isnan 应在标头 cmath 中定义,因为 C++11。 Qt 头文件确实包含此头文件。当我在 Visual Studio 中检查 cmath 时,我看不到名为 isnan 的函数。

我的结论是 VS2012 缺少这个 C++11 函数是否正确?起初我以为我可能必须以某种方式启用 C++11 支持,但根据 this answer 默认情况下启用 C++11 支持。鉴于binary downloads for Qt are available for VS2010 and VS2012,显然可以使用各自的编译器进行构建。有什么我遗漏的吗?

【问题讨论】:

标签: c++ qt visual-studio-2012 c++11 compiler-errors


【解决方案1】:

isnan 从 Visual Studio 2013 开始在 Visual Studio 的标准库中实现。

很可能有某种定义告诉它您没有可用的std::isnan

【讨论】:

  • 我会尝试#ifdef isnan 作为检查,如果未定义函数,则此符号应可用作宏(宏解释错误消息)。
  • 谢谢。我将尝试将 -no-c++11 传递给 Qt 的配置工具,看看是否可行。如果没有,我将按照您的建议检查定义。
  • 我只是看了一眼代码,VS2010 或 2012 无法编译。我猜这个模块不包括在内。
猜你喜欢
  • 2016-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-20
  • 1970-01-01
相关资源
最近更新 更多