-
Notifications
You must be signed in to change notification settings - Fork 543
CXX-2629 Remove requirement to set /Zc:__cplusplus
in MSVC flags
#924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note option requirements for <= 3.7.0. Note /EHsc is required for <= 3.7.0.
Codecov Report
@@ Coverage Diff @@
## master #924 +/- ##
==========================================
- Coverage 91.28% 91.28% -0.01%
==========================================
Files 384 384
Lines 23324 23324
==========================================
- Hits 21292 21291 -1
- Misses 2032 2033 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
/Zc:__cplusplus
in MSVC flags
@@ -48,7 +48,7 @@ using ::boost::make_unique; | |||
BSONCXX_INLINE_NAMESPACE_END | |||
} // namespace bsoncxx | |||
|
|||
#elif __cplusplus >= 201402L | |||
#elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was concerned about testing __cplusplus
before _MSVC_LANG
, but it seems Catch2 does this as well, so I believe this should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Background & Motivation
The current documented install instructions note:
Setting
CMAKE_CXX_FLAGS
appears to have the side-effect of overwriting the default MSVC flags set by cmake.For example, if
CMAKE_CXX_FLAGS
is not set, this is the output I get with cmake 3.23.1 on my Windows machine:Following the C++ driver instructions results in
CMAKE_CXX_FLAGS
only including/Zc:__cplusplus
.Excluding
/EHsc
appears particularly problematic./EHsc
is the documented default for the exception handling model:Not including the
/EHsc
flag results in warnings during compilation:Setting
/EHsc
appears to fix anInternal compiler error
reported in CXX-2616.https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ notes:
This PR adds a check for
_MSVC_LANG
, to remove the requirement to pass/Zc:__cplusplus
. Following the documentation no longer results in omitting the/EHsc
flag.