-
Notifications
You must be signed in to change notification settings - Fork 13.5k
C++20 modules available but __cpp_modules
not defined
#71364
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
Comments
@llvm/issue-subscribers-c-20 Author: Boris Kolpackov (boris-kolpackov)
While Clang now enables C++20 modules by default with `-std=c++20` and later, it does not appear to define the `__cpp_modules` feature test macros (which should have the value of `201907L`; see https://en.cppreference.com/w/cpp/feature_test). I've tested this with up to Clang 18 pre-release (`20231102103655+18839aec4ed1`).
Is there a reason for omitting this macro for now or is it an oversight that could be fixed? In @iains @ChuanqiXu9 @dwblaikie |
@llvm/issue-subscribers-clang-modules Author: Boris Kolpackov (boris-kolpackov)
While Clang now enables C++20 modules by default with `-std=c++20` and later, it does not appear to define the `__cpp_modules` feature test macros (which should have the value of `201907L`; see https://en.cppreference.com/w/cpp/feature_test). I've tested this with up to Clang 18 pre-release (`20231102103655+18839aec4ed1`).
Is there a reason for omitting this macro for now or is it an oversight that could be fixed? In @iains @ChuanqiXu9 @dwblaikie |
The major reason is that we haven't marked the status of Modules as complete now. See https://clang.llvm.org/cxx_status.html The reason behind this may be a different strategy to claim a feature as stable. For example, the support of coroutines in clang is marked as partial before Mar this year: https://discourse.llvm.org/t/rfc-could-we-mark-coroutines-as-unreleased-now/69220, while it is already used in production for years. |
This feels inconsistent to me: you enable modules by default in Perhaps a compromise would be to define this macro but with a value that is an earlier date. I believe GCC does it this way. |
Sounds good. I'd like to define the macro later if no objection comes in. |
I think there's evidence that defining the macro at all when modules is not complete will cause problems in practice: https://sourcegraph.com/search?q=context:global+%23if+defined%28__cpp_modules%29+-file:.*test.*+-file:.*clang.*+-file:.*gcc.*&patternType=standard&case=yes&sm=1&groupBy=repo In general, I think we don't want to define feature test macros until we're comfortable claiming we fully support the functionality. The one big exception to this is when system headers (mis)use the feature testing macros in a way that's critical for us to support. |
While Clang now enables C++20 modules by default with
-std=c++20
and later, it does not appear to define the__cpp_modules
feature test macros (which should have the value of201907L
; see https://en.cppreference.com/w/cpp/feature_test). I've tested this with up to Clang 18 pre-release (20231102103655+18839aec4ed1
).Is there a reason for omitting this macro for now or is it an oversight that could be fixed? In
build2
we currently define this macro on the command line which adds quite a bit of noise.@iains @ChuanqiXu9 @dwblaikie
The text was updated successfully, but these errors were encountered: