Skip to content

Commit 4740e92

Browse files
committed
[libc++] Improve LIBCXX_ENABLE_INCOMPLETE_FEATURES.
@tcanens pointed out the current behavior of the macro breaks the usage pattern described in http://wg21.link/SD6 ``` ``` To support this usage pattern the hard errror is removed. Instead the header includes nothing but the `<version>` header. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D107134 (cherry picked from commit d618a1c)
1 parent 7563727 commit 4740e92

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

libcxx/include/format

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ namespace std {
5555
5656
*/
5757

58+
// Make sure all feature tests macros are always available.
59+
#include <version>
60+
// Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled
61+
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
62+
5863
#include <__config>
5964
#include <__format/format_error.h>
6065
#include <__format/format_parse_context.h>
61-
#include <version>
62-
63-
#if defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
64-
# error "The Format library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
65-
#endif
6666

6767
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
6868
# pragma GCC system_header
@@ -81,4 +81,6 @@ _LIBCPP_END_NAMESPACE_STD
8181

8282
_LIBCPP_POP_MACROS
8383

84+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
85+
8486
#endif // _LIBCPP_FORMAT

libcxx/include/ranges

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ namespace std::ranges {
160160
161161
*/
162162

163+
// Make sure all feature tests macros are always available.
164+
#include <version>
165+
// Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled
166+
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
167+
163168
#include <__config>
164169
#include <__ranges/access.h>
165170
#include <__ranges/all.h>
@@ -181,11 +186,6 @@ namespace std::ranges {
181186
#include <initializer_list> // Required by the standard.
182187
#include <iterator> // Required by the standard.
183188
#include <type_traits>
184-
#include <version>
185-
186-
#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
187-
# error "The Ranges library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
188-
#endif
189189

190190
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
191191
#pragma GCC system_header
@@ -204,4 +204,6 @@ _LIBCPP_END_NAMESPACE_STD
204204

205205
_LIBCPP_POP_MACROS
206206

207+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
208+
207209
#endif // _LIBCPP_RANGES

0 commit comments

Comments
 (0)