为什么我不能在 C++ Builder 中编译 IsNan

Nig*_*ens 1 c++ math c++builder

我正在使用 C++ Builder XE 并想检查浮点值是否有效。根据帮助,在math.h中,有一个调用

bool IsNan(float value)
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试编译它时,它告诉我

Call to undefined function 'IsNan'
Run Code Online (Sandbox Code Playgroud)

查看 math.h,没有 isnan 这样的东西(我使用了不区分大小写的搜索)

我是在做傻事还是什么?

mat*_*975 5

要使用 Embarcadero 内置IsNan()功能,您需要包含(无论如何都适用于 XE4)

#include <System.Math.hpp>
Run Code Online (Sandbox Code Playgroud)

如果您使用的是基本 XE,那么您需要

#include <Math.hpp>
Run Code Online (Sandbox Code Playgroud)

后者也适用于 XE4,尽管帮助表明System.Math.hpp需要这样做。

  • `Math.hpp` 包含 `System.Math.hpp` 以向后兼容 Pre-UnitScopeName 代码,这就是为什么 `Math.hpp` 可以在 XE4 上运行,即使实际上需要 `System.Math.hpp`。 (2认同)