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

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

原文地址:https://www.cnblogs.com/aobosir/p/5928659.html