[CXX-1613] Error compiling on MSVC with C++17 as target Created: 18/Jul/18 Updated: 28/Oct/23 Resolved: 27/Nov/18 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | BSON, Documentation |
| Affects Version/s: | None |
| Fix Version/s: | 3.5.0 |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Miguel Cunha | Assignee: | Kevin Albertson |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | FY2019Q4 Quick Wins (C and CXX) |
| Description |
|
On mongo-cxx-driver/src/bsoncxx/stdx/make_unique.hpp, when building with MSVC targeted for C++17, we have an error, because of MSVC problem with __cplusplus variable . Because of that, we get the error "Cannot find a valid polyfill for make_unique". To fix this, we can either:
|
| Comments |
| Comment by Kevin Albertson [ 27/Nov/18 ] |
|
The installation docs have been updated to include instructions for building with VS 2017 with C++17 standard (bottom of Step 4). To do so, configure cmake with -DCMAKE_CXX_FLAGS="/Zc:__cplusplus". |
| Comment by Githook User [ 27/Nov/18 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@10gen.com', 'username': 'kevinAlbs'}Message: |
| Comment by Andrew Morrow (Inactive) [ 12/Oct/18 ] |
|
OK. I think my preference would really be to make no changes, but to add to our documentation a note that if you want to use C+17 with MSVC 2017, you need to add /Zc:__cplusplus to your C++ flags in your CMake invocation, by one mechanism or another. I expect that at some point CMake will know to do this automatically when CMAKE_CXX_STANDARD is set to C++17 and MSVC 2017 is in use, and I'd rather not clutter our code with workarounds for something that can be addressed by passing a flag on the command line. |
| Comment by Kevin Albertson [ 12/Oct/18 ] |
|
Not AFAICT. I've seen other solutions to checking for make_unique that test compiling a small file with make_unique to see if it's supported by the compiler via check_cxx_source_compiles. CMake can also include feature test macros, but none for make_unique. |
| Comment by Andrew Morrow (Inactive) [ 12/Oct/18 ] |
|
Are we sure that the CMake maintainers haven't addressed this already somehow? |
| Comment by Kevin Albertson [ 10/Oct/18 ] |
|
Thanks for the report mpoeira! We're investigating the solutions you proposed. |
| Comment by Kevin Albertson [ 20/Sep/18 ] |
|
Related PR https://github.com/mongodb/mongo-cxx-driver/pull/624 |