c++ Builder调用未定义函数hypot/ceil/floor/fab
C++Builder call to undefined functions hypot/ceil/floor/fabs
最近,在我的项目中添加了一个头文件后,我无法编译我的应用程序-我添加了空白的头文件,然后出现了奇怪的错误:
[bcc32 Error] SystemTypes.h(79): E2268 Call to undefined function 'hypot'
[bcc32 Error] SystemTypes.h(511): E2268 Call to undefined function 'ceil'
[bcc32 Error] SystemTypes.h(525): E2268 Call to undefined function 'fabs'
这些错误"不知从何而来"——我也玩过另一个空项目,它们在将调试模式更改为发布模式后出现。我怎样才能修好它们呢?我不知道他们为什么会出现。下面可以看到一个错误的完整解析器上下文:
Full parser context
Project3.cpp(3): #include c:program files (x86)embarcaderostudio16.0includewindowsvclvcl.h
vcl.h(10): #include c:program files (x86)embarcaderostudio16.0includewindowsvclbasepch0.h
basepch0.h(63): #include c:program files (x86)embarcaderostudio16.0includewindowsrtlSystem.Types.hpp
System.Types.hpp(19): #include c:program files (x86)embarcaderostudio16.0includewindowsrtlSystemTypes.h
SystemTypes.h(32): namespace System
SystemTypes.h(32): namespace Types
SystemTypes.h(33): class TSmallPoint
SystemTypes.h(87): decision to instantiate: double TSmallPoint::Distance(const TSmallPoint &) const
--- Resetting parser context for instantiation...
SystemTypes.h(84): parsing: double TSmallPoint::Distance(const TSmallPoint &) const
简短的回答:正如@Flame spotter所说,#include <math.h>
.
长回答:这些信息告诉你什么是错的:
SystemTypes.h(87): decision to instantiate: double TSmallPoint::Distance(const TSmallPoint &) const
--- Resetting parser context for instantiation...
SystemTypes.h(84): parsing: double TSmallPoint::Distance(const TSmallPoint &) const
编译器试图实例化TSmallPoint::Distance
时遇到了一个问题。如果您查看TSmallPoint::Distance
的实现,您将看到如下内容:
double Distance(const TSmallPoint& p2) const _ALWAYS_INLINE {
return hypot(p2.x - this->x, p2.y - this->y);
}
还有关于hypot
的神秘参考,这给你带来了麻烦。事实上,SystemTypes.h
引用hypot
而不包括<math.h>
本身是一个错误。它在我的XE2副本中是固定的(我不再有XE来检查我自己),但是你应该能够通过包括<math.h>
来解决它。(如果你愿意,你甚至可以编辑SystemTypes.h
并在那里添加include)
至于为什么它出现在发布版本而不是调试版本-我不确定。这是一个内联函数,内联函数在发布版本和调试版本中的处理方式通常不同,"实例化"的引用听起来可能也有一些模板实例化,这可能会使事情进一步复杂化。c++ Builder的编译器不是很符合标准,我不总是理解它是如何以及何时决定抱怨某些事情的。
你需要这个include语句:
#include <math.h>
相关文章:
- C++:floor unix时间戳到UTC月份
- 在 gdb 中运行 floor() 或 ceil()
- C++使用 CEIL 和长度输出不正确的值
- ceil、floor 和 round 在转换为整数时会遇到精度损失问题吗?
- C++ ceil() 在傀儡排序中不起作用
- 什么时候会static_casting结果 ceil 妥协结果
- 舍入比LLVM中的floor/ceil/int慢得多
- 在C++GMP中使用ceil
- C++ floor() 将值减少 1
- CEIL对于确切的整数部门来说太高了
- 如何将sqrt和ceil与Boost::multiprecision一起使用
- 用于正浮点值的 floor 和 ceil
- Ceil函数在寻找中值中的作用
- 删除c++中小数点后的数字(不带floor()函数)
- Visual Studio不允许我使用sqrt或floor,对重载函数的模糊调用
- ceil() 和 floor() 在 C++ 中用于size_t类型的函数
- 在C++中使用ceil函数时出现计算错误
- 在c++中,使用ceil除法是行不通的
- c++ Builder调用未定义函数hypot/ceil/floor/fab
- OpenACC and floor/ceil functions