[libcxx-commits] [PATCH] D142588: [libc++] Remove use of internal glibc macros to determine if c8rtomb() and mbrtoc8() are present
Tom Honermann via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 25 15:17:46 PST 2023
tahonermann created this revision.
tahonermann added reviewers: ldionne, libc++, Mordante.
Herald added a project: All.
tahonermann requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
When support for declaring the c8rtomb() and mbrtoc8() functions within the std namespace was added in commit 7e7013c5d4b1b3996c8dba668c5a94bb33b2999b <https://reviews.llvm.org/rG7e7013c5d4b1b3996c8dba668c5a94bb33b2999b>, internal glibc macros were used to determine if C2X extensions are enabled. Specifically, a check for whether `__GLIBC_USE` is defined and whether `__GLIBC_USE(ISOC2X)` is non-0 was added. `__GLIBC_USE` is an internal detail of the glibc implementation that may be changed or removed in the future potentially leading to inconsistency or compilation failures. This change removes the use of the internal glibc macro to avoid such problems. Unfortunately, without another mechanism to determine if C2X extensions are enabled, this removal will result in inconsistent declarations of the c8rtomb() and mbrtoc8() functions; when C++ char8_t support is not enabled, but C2X extensions are, these functions will be declared in the global namespace but not in the std namespace. This situation will improve when C23 support is finalized and the check can be re-implemented using `__STDC_VERSION__`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142588
Files:
libcxx/include/__config
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1223,12 +1223,12 @@
// functions are declared by the C library.
# define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
-// __cpp_char8_t is defined or if C2X extensions are enabled. Unfortunately,
-// determining the latter depends on internal GNU libc details. If the
-// __cpp_char8_t feature test macro is not defined, then a char8_t typedef
-// will be declared as well.
-# if defined(_LIBCPP_GLIBC_PREREQ) && defined(__GLIBC_USE)
-# if _LIBCPP_GLIBC_PREREQ(2, 36) && (defined(__cpp_char8_t) || __GLIBC_USE(ISOC2X))
+// __cpp_char8_t is defined or if C2X extensions are enabled. Determining
+// the latter depends on internal GNU libc details that are not appropriate
+// to depend on here, so any declarations present when __cpp_char8_t is not
+// defined are ignored.
+# if defined(_LIBCPP_GLIBC_PREREQ)
+# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
# undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
# endif
# endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142588.492266.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230125/15320ecd/attachment.bin>
More information about the libcxx-commits
mailing list