[libcxx-commits] [PATCH] D107134: [libc++] Improve LIBCXX_ENABLE_INCOMPLETE_FEATURES.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 30 00:18:03 PDT 2021


Mordante created this revision.
Mordante added a reviewer: ldionne.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

@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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107134

Files:
  libcxx/include/format
  libcxx/include/ranges


Index: libcxx/include/ranges
===================================================================
--- libcxx/include/ranges
+++ libcxx/include/ranges
@@ -166,6 +166,11 @@
 
 */
 
+// Make sure all feature tests macros are always available.
+#include <version>
+// Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
 #include <__config>
 #include <__ranges/access.h>
 #include <__ranges/all.h>
@@ -188,11 +193,6 @@
 #include <initializer_list> // Required by the standard.
 #include <iterator>         // Required by the standard.
 #include <type_traits>
-#include <version>
-
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-# error "The Ranges library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -211,4 +211,6 @@
 
 _LIBCPP_POP_MACROS
 
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
 #endif // _LIBCPP_RANGES
Index: libcxx/include/format
===================================================================
--- libcxx/include/format
+++ libcxx/include/format
@@ -55,14 +55,14 @@
 
 */
 
+// Make sure all feature tests macros are always available.
+#include <version>
+// Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
 #include <__config>
 #include <__format/format_error.h>
 #include <__format/format_parse_context.h>
-#include <version>
-
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
-# error "The Format library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -81,4 +81,6 @@
 
 _LIBCPP_POP_MACROS
 
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
 #endif // _LIBCPP_FORMAT


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107134.362978.patch
Type: text/x-patch
Size: 2003 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210730/18083179/attachment.bin>


More information about the libcxx-commits mailing list