Skip to content
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

Make MSVC use [[nodiscard]] #2615

Merged
merged 3 commits into from
Nov 26, 2021
Merged

Make MSVC use [[nodiscard]] #2615

merged 3 commits into from
Nov 26, 2021

Conversation

AlexGuteniev
Copy link
Contributor

Uniformly detect attributes for __cplusplus and _MSVC_LANG

Uniformly detect attributes for __cplusplus and _MSVC_LANG
Comment on lines +85 to +89
#ifdef _MSVC_LANG
# define FMT_CPLUSPLUS _MSVC_LANG
#else
# define FMT_CPLUSPLUS __cplusplus
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

What is going on here? Doesn't MSVC use the standard __cplusplus macro?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/Zc:__cplusplus enables updated C++ macro. By default __cplusplus is defined to some ancient value.

As I read in MSVC STL chat, the reason for this default behavior is the compatibility with some open-source code, in which higher __cplusplus values enable not only legitimate C++ features, but also gcc extensions.

You already had _MSVC_LANG for [[fallthrough]], I'm just propagating it a bit further.

@vitaut vitaut merged commit 201971e into fmtlib:master Nov 26, 2021
@vitaut
Copy link
Contributor

vitaut commented Nov 26, 2021

Thank you

@AlexGuteniev AlexGuteniev deleted the nodiscard branch November 26, 2021 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants