Skip to content

Commit d618a1c

Browse files
mordanteldionne
authored andcommitted
[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 ``` # if __has_include(<optional>) # include <optional> # if __cpp_lib_optional >= 201606 # define have_optional 1 # endif ``` 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
1 parent afc6b09 commit d618a1c

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
@@ -170,6 +170,11 @@ namespace std::ranges {
170170
171171
*/
172172

173+
// Make sure all feature tests macros are always available.
174+
#include <version>
175+
// Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled
176+
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
177+
173178
#include <__config>
174179
#include <__ranges/access.h>
175180
#include <__ranges/all.h>
@@ -193,11 +198,6 @@ namespace std::ranges {
193198
#include <initializer_list> // Required by the standard.
194199
#include <iterator> // Required by the standard.
195200
#include <type_traits>
196-
#include <version>
197-
198-
#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
199-
# error "The Ranges library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
200-
#endif
201201

202202
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
203203
#pragma GCC system_header
@@ -216,4 +216,6 @@ _LIBCPP_END_NAMESPACE_STD
216216

217217
_LIBCPP_POP_MACROS
218218

219+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
220+
219221
#endif // _LIBCPP_RANGES

0 commit comments

Comments
 (0)