MongoDB uses C + + driver compilation error resolution in MFC

Source: Internet
Author: User
Tags creative commons attribution

Today, using the MongoDB C + + driver, there was an error when compiling the connection, and the string_data.h of the 93-line Max macro is displayed, which is not itself called the Max macro, but instead calls the

Std::numeric_limits<size_t>::max

This is to generate an error, by searching for a workaround (reference URL: http://blog.chinaunix.net/uid-17102734-id-2830143.html), enclose the function in parentheses to avoid confusion with Windows definitions, as detailed below

Original definition:

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

Modified after definition:

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

Note that the parentheses are added so that you can solve the compilation problem


This work is licensed under the Creative Commons Attribution-NonCommercial use-Share 4.0 International license agreement in the same way.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.