Skip to content

Enhance /std documentation with reference to /Zc:__cplusplus - #5010

Merged
Courtney Wales (Court72) merged 5 commits into
MicrosoftDocs:mainfrom
wsfulton:wsfulton-std-zc__cplusplus
Apr 5, 2024
Merged

Enhance /std documentation with reference to /Zc:__cplusplus#5010
Courtney Wales (Court72) merged 5 commits into
MicrosoftDocs:mainfrom
wsfulton:wsfulton-std-zc__cplusplus

Conversation

@wsfulton

Copy link
Copy Markdown
Contributor

This change makes it much clearer as to what is required for C++ standards conformance when using the /std option - Specify Language Standard Version for C++.

Motivation: The /std option implies standards conformance to C++ standards, yet it does not provide the most basic of conformance as it does not predefine the __cplusplus macro as mandated by the C++ standard (in section "Predefined macro names" - [cpp.predefined]). In order to conform to the standard, the /Zc:__cplusplus option is additionally required and this should be very clear in the documentation.

This change makes it much clearer as to what is required for  C++ standards conformance when using the /std option - Specify Language Standard Version for C++.

Motivation: The /std option implies standards conformance to C++ standards, yet it does not provide the most basic of conformance as it does not predefine the __cplusplus macro as mandated by the C++ standard (in section "Predefined macro names" - [cpp.predefined]). In order to conform to the standard, the /Zc:__cplusplus option is additionally required and this should be very clear in the documentation.
@prmerger-automator

Copy link
Copy Markdown
Contributor

William S Fulton (@wsfulton) : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 113ee82:

✅ Validation status: passed

File Status Preview URL Details
docs/build/reference/std-specify-language-standard-version.md ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@Court72

Copy link
Copy Markdown
Contributor

Tyler Whitney (@TylerMSFT)

Can you review the proposed changes?

When the changes are ready for publication, add a #sign-off comment to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator Bot added the aq-pr-triaged Tracking label for the PR review team label Apr 5, 2024
Add info about what to set __cplusplus to
@prmerger-automator

Copy link
Copy Markdown
Contributor

William S Fulton (@wsfulton) : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@TylerMSFT Tyler Whitney (TylerMSFT) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

William S Fulton (@wsfulton), thank you for making this valuable contribution to the docs. I augmented it a little to provide more context.
Really appreciate you taking the time to make this update.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 3059e82:

✅ Validation status: passed

File Status Preview URL Details
docs/build/reference/std-specify-language-standard-version.md ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 1356b99:

✅ Validation status: passed

File Status Preview URL Details
docs/build/reference/std-specify-language-standard-version.md ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@TylerMSFT

Copy link
Copy Markdown
Collaborator

#sign-off

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 8c8f2dc:

💡 Validation status: suggestions

File Status Preview URL Details
docs/build/reference/std-specify-language-standard-version.md 💡Suggestion Details

docs/build/reference/std-specify-language-standard-version.md

  • Line 34, Column 3: [Suggestion: table-syntax-invalid - See documentation] Table syntax is invalid. Ensure your table includes a header and is surrounded by empty lines.

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

@Court72

Copy link
Copy Markdown
Contributor

Thank you, Tyler Whitney (@TylerMSFT)!

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit c54b897:

✅ Validation status: passed

File Status Preview URL Details
docs/build/reference/std-specify-language-standard-version.md ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@wsfulton

Copy link
Copy Markdown
Contributor Author

Thanks Tyler Whitney (@TylerMSFT), wonderful that this information can be conveyed on the /std documentation page and the reformulated wording is much better than the current official documentation which omits this important information.

However, I do feel that the simple one sentence I proposed is perhaps clearer, more relevant and succinct for the /std page. The primary simple message on the /std page is that one should seriously look at adding in the /zc:__cplusplus option and look at the documentation on this page.

I'm not sure repeating the details of the exact values of __cplusplus from the /zc:__cplusplus page is a good idea, I would leave them on that page and keep a simple link to it.

The reasons you added for not setting __cplusplus according to that mandated by the standard is very useful, but again, getting bogged down with the values in the /std page doesn't seem right and is best left on the /zc:__cplusplus page.

Obviously it would be the right thing if /std did the right thing and was truly standards conforming, but as this is not the case chosen by the MSVC developers, a simple succinct fix for this omission is what a user is interested in and is what the documentation should aim for.

I would suggest this combination:

[!IMPORTANT]
The [`/Zc:__cplusplus`](zc-cplusplus.md) option must additionally be used for the `__cplusplus` macro to be correctly defined for the appropriate C++ standard.
Without the addition of `/Zc:__cplusplus`, the value of the `__cplusplus` macro is hard wired to 199711L (c++98) in order to support some existing code that depends on this macro being set to this value.

@TylerMSFT

Tyler Whitney (TylerMSFT) commented Apr 5, 2024

Copy link
Copy Markdown
Collaborator

We can't tell people they have to set it and then not tell them to what, or hope they go to another topic to find the info. I'll keep the table.

@wsfulton

William S Fulton (wsfulton) commented Apr 6, 2024

Copy link
Copy Markdown
Contributor Author

Tyler Whitney (@TylerMSFT), I am sorry, but am a confused by the last comment as users don't need to set the value of __cplusplus, the value is set automatically via a combination of /std and /Zc:__cplusplus options.

If you feel a table is needed on the /std page, then please consider copying the table from the zc-cplusplus.md page, because in comparison:

  1. it is technically accurate - does not miss the L suffix.
  2. it is complete - contains 3 additional rows including /std:c++latest.
  3. and most importantly, by using 3 columns, is unambiguously and absolutely clear what the __cplusplus value is for all combinations of the two options.

@TylerMSFT

Tyler Whitney (TylerMSFT) commented Apr 9, 2024

Copy link
Copy Markdown
Collaborator

I see what you are saying. I update this in PR #5538

@wsfulton

Copy link
Copy Markdown
Contributor Author

Excellent, thanks, I found the commit to main here: 2e67cbc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants