error: C2065: 'DBL_MAX' : undeclared identifier (in VS2008 but not in VS2010)

error: C2065: 'DBL_MAX' : undeclared identifier (in VS2008 but not in VS2010)

在我的代码中,我使用 DBL_MAX,它在 math.h 中定义。在 VS2010 中它工作正常,但在 VS2008 中我得到一个错误:

error: C2065: 'DBL_MAX' : undeclared identifier

DBL_MAX 在 VS2008 中可用吗?

原来我是傻子,我应该检查实际的 header - 它在 float.h,而不是 math.h。似乎 math.h 在 VS2010 中包含 float.h 但在 VS2008 中不包含

让我感到困惑的是它在 VS2010 中工作,所以我假设 DBL_MAX 它不适用于 VS2008。

所以添加它解决了问题:

#include <math.h>
#include <float.h>

我发布这篇文章是为了防止其他人犯同样的错误。