MongoDB在MFC下使用C++驱动编译错误的解决

今天使用MongoDB的C++驱动,在编译连接的时候一直出现错误,显示的string_data.h下93行max宏的问题,可视其本身并不是调用max宏,而是调用

std::numeric_limits<size_t>::max

这样就是产生错误,通过搜索发现解决方法(参考网址:http://blog.chinaunix.net/uid-17102734-id-2830143.html),将该函数用括号括起来,避免windows定义的混淆,具体修改如下

原始定义:

StringData substr( size_t pos, size_t n = std::numeric_limits<size_t>::max() ) const;

修改后定义:

StringData substr( size_t pos, size_t n = (std::numeric_limits<size_t>::max)() ) const;

注意添加的括号,这样就可以解决编译问题了

原文地址:https://www.cnblogs.com/madhenry/p/3796547.html