Skip to content

Commit

Permalink
[libc++] Improve LIBCXX_ENABLE_INCOMPLETE_FEATURES.
Browse files Browse the repository at this point in the history
@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)
  • Loading branch information
mordante committed Aug 2, 2021
1 parent 7563727 commit 4740e92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions libcxx/include/format
Expand Up @@ -55,14 +55,14 @@ namespace std {
*/

// 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
Expand All @@ -81,4 +81,6 @@ _LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)

#endif // _LIBCPP_FORMAT
12 changes: 7 additions & 5 deletions libcxx/include/ranges
Expand Up @@ -160,6 +160,11 @@ namespace std::ranges {
*/

// 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>
Expand All @@ -181,11 +186,6 @@ namespace std::ranges {
#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
Expand All @@ -204,4 +204,6 @@ _LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)

#endif // _LIBCPP_RANGES

0 comments on commit 4740e92

Please sign in to comment.