Nikolas Klauser ba87515fea
[libc++][RFC] Always define internal feature test macros (#89178)
Currently, the library-internal feature test macros are only defined if
the feature is not available, and always have the prefix
`_LIBCPP_HAS_NO_`. This patch changes that, so that they are always
defined and have the prefix `_LIBCPP_HAS_` instead. This changes the
canonical use of these macros to `#if _LIBCPP_HAS_FEATURE`, which means
that using an undefined macro (e.g. due to a missing include) is
diagnosed now. While this is rather unlikely currently, a similar change
in `<__configuration/availability.h>` caught a few bugs. This also
improves readability, since it removes the double-negation of `#ifndef
_LIBCPP_HAS_NO_FEATURE`.

The current patch only touches the macros defined in `<__config>`. If
people are happy with this approach, I'll make a follow-up PR to also
change the macros defined in `<__config_site>`.
2024-10-12 09:49:52 +02:00

29 lines
1.1 KiB
C++

// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
export namespace std {
// Note the Standard does not mark these symbols optional, but libc++'s header
// does. So this seems strictly not to be conforming.
// mbstate_t is conditionally here, but always present in cwchar.cppm. To avoid
// conflicing declarations omit the using here.
// size_t is conditionally here, but always present in cstddef.cppm. To avoid
// conflicing declarations omit the using here.
#if _LIBCPP_HAS_C8RTOMB_MBRTOC8
using std::mbrtoc8 _LIBCPP_USING_IF_EXISTS;
using std::c8rtomb _LIBCPP_USING_IF_EXISTS;
#endif
using std::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
using std::c16rtomb _LIBCPP_USING_IF_EXISTS;
using std::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
using std::c32rtomb _LIBCPP_USING_IF_EXISTS;
} // namespace std