disl 发表于 2015-7-10 09:09:49

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

  今天使用MongoDB的C++驱动,在编译连接的时候一直出现错误,显示的string_data.h下93行max宏的问题,可视其本身并不是调用max宏,而是调用
std::numeric_limits::max
  这样就是产生错误,通过搜索发现解决方法(参考网址:http://blog.chinaunix.net/uid-17102734-id-2830143.html),将该函数用括号括起来,避免windows定义的混淆,具体修改如下
  原始定义:
StringData substr( size_t pos, size_t n = std::numeric_limits::max() ) const;
  修改后定义:
StringData substr( size_t pos, size_t n = (std::numeric_limits::max)() ) const;
  注意添加的括号,这样就可以解决编译问题了



本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
页: [1]
查看完整版本: MongoDB在MFC下使用C++驱动编译错误的解决