您的位置:首页 > 编程语言 > C语言/C++

std::min error C2059: 语法错误:“::” 的解决方法

2016-07-09 02:08 363 查看

std::min error C2059: 语法错误:“::” 的解决方法

下面这段代码:

size_t n = std::min(count_, num_elements);


编译会出现这样的错误:

1> error C2059: 语法错误:“::”
1> error C2589: “(”:“::”右边的非法标记


解决办法

std::min
用括号括起来,问题解决。

size_t n = (std::min)(count_, num_elements);


同样的问题

dist_index_.resize(capacity_, DistIndex(std::numeric_limits<DistanceType>::max(),-1));


同样的解决方法

解决办法都是一样的,把
std::numeric_limits<DistanceType>::max
用括号括起来:

dist_index_.resize(capacity_, DistIndex((std::numeric_limits<DistanceType>::max)(),-1));


为什么会出现这个错误

参考网站:

http://stackoverflow.com/questions/2789481/problem-calling-stdmax

你的程序使用PCL库,并且在程序中包含了头文件
#include <windows.h>


windows.h
这个库里面定义了一些,比如minmaxPCL库里面使用了同样名字的,但是不是
windows.h
里面的

现在具体,我也不清楚是怎么回事,所以我不敢瞎写。

参考网站:

http://blog.csdn.net/ben_ben_niao/article/details/45971095
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息