今天使用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;

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

相关文章:

  • 2022-01-08
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2021-05-19
  • 2021-06-05
  • 2021-09-27
  • 2022-03-01
猜你喜欢
  • 2021-07-13
  • 2021-12-23
  • 2021-11-25
  • 2021-05-31
  • 2022-12-23
  • 2021-12-10
  • 2021-11-03
相关资源
相似解决方案