-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
C++26 freestanding feature-test macros #3837
C++26 freestanding feature-test macros #3837
Conversation
Apply them to older modes when the corresponding feature/header is available.
CC-ing @ben-craig. |
You may want to drop a static assert somewhere checking
The standard doesn't really talk about older modes, and I didn't do anything to audit which modes / standards would make sense. Sure, all the stuff in C++03 from the |
The value
I don't actually know what |
From the paper:
Example... #if (__STDC_HOSTED__ || \
(defined(__cpp_lib_freestanding_feature_test_macros) && \
__cpp_lib_freestanding_feature_test_macros >= 202112))
#define TRUTHFUL_MACROS 1
#else
#define TRUTHFUL_MACROS 0
#endif
// see if filesystem happens to be supported on this possibly freestanding environment
#if TRUTHFUL_MACROS && defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L
// hosted and freestanding extension success path
#else
// fallback path
#endif So that macro should only be important for actual freestanding implementations. |
Because these feature-test macros are essentially defined unconditionally, we can accept this as a special exception to our "no C++26 PRs yet" policy. |
tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
Thanks! After fixing a copy-paste typo, looks perfect! 😻 |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for implementing all of these feature-test macros! 🎉 ⚙️ 🚀 |
Fixes #3793. Fixes #3794. Fixes #3795.
(But we may need to reopen these issues and #2914 in future once freestanding mode is added. See #1289.)
It seems to me that hosted implementations are required to provide all of these macros (see "Rejected alternatives" in WG21-P2198R7). I think it makes more sense to define them in older modes when the corresponding feature/header is available.
Possibly related question: should we leave feature-test macros for non-core components not defined when
_ENFORCE_ONLY_CORE_HEADERS
is defined?