赞
踩
自己在编译 c++ 程序的时候遇到如下报错
error: call of overloaded ‘abs(unsigned int)’ is ambiguous
unsigned int di = abs(i - src_i);
出现这个错误,首先自己检查了一下头文件包含的问题,发现自己已经包含了头文件
#include <stdlib.h>
然后查阅资料发现,是 abs() 函数定义的问题。需要在里面增加 int
强制类型转换,也就是改成如下形式,就可以编译通过啦~~~~
unsigned int di = abs(int(i - src_i));
参考链接:
[1] C++: 解释error: call of overloaded ‘abs(int)’ is ambiguous – https://blog.csdn.net/linwh8/article/details/50754147/
[2] 【已解决】error: call of overloaded ‘abs(unsigned int)’ is ambiguous – https://blog.csdn.net/lun55423/article/details/109037113
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。