[libcxx-commits] [libcxx] [AIX][libc++] Fix redefinition of wchar_t overloads on AIX (PR #201432)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 3 11:58:24 PDT 2026
https://github.com/Himadhith created https://github.com/llvm/llvm-project/pull/201432
On AIX, the system headers have a circular dependency: `wctype.h → wchar.h → wctype.h` which causes wchar.h to be processed multiple times.
The existing `_LIBCPP_WCHAR_H` include guard does not protect because wchar.h is a textual header and they get their own pre-processing per module compilation.
>From e8303d979af9fb0e60da06627dcce88465ec1bbf Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Wed, 3 Jun 2026 14:48:19 -0400
Subject: [PATCH] [AIX][libc++] Fix redefinition of wchar_t overloads on AIX
---
libcxx/include/wchar.h | 2 ++
libcxx/test/extensions/clang/clang_modules_include.gen.py | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/wchar.h b/libcxx/include/wchar.h
index a932dd266b862..8f652fee873fc 100644
--- a/libcxx/include/wchar.h
+++ b/libcxx/include/wchar.h
@@ -137,6 +137,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
# if _LIBCPP_HAS_WIDE_CHARACTERS
# if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
+# if defined(_AIX) && !defined(_LIBCPP_WCHAR_H_OVERLOADS)
extern "C++" {
inline _LIBCPP_HIDE_FROM_ABI wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {
return (wchar_t*)wcschr(__s, __c);
@@ -200,6 +201,7 @@ size_t mbsnrtowcs(
size_t wcsnrtombs(
char* __restrict __dst, const wchar_t** __restrict __src, size_t __nwc, size_t __len, mbstate_t* __restrict __ps);
} // extern "C"
+# endif // _LIBCPP_WCHAR_H_OVERLOADS
# endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
# endif // _LIBCPP_WCHAR_H
diff --git a/libcxx/test/extensions/clang/clang_modules_include.gen.py b/libcxx/test/extensions/clang/clang_modules_include.gen.py
index 28661049d6e85..f0de60bacd7a7 100644
--- a/libcxx/test/extensions/clang/clang_modules_include.gen.py
+++ b/libcxx/test/extensions/clang/clang_modules_include.gen.py
@@ -30,8 +30,6 @@
# TODO: Investigate why this doesn't work on Picolibc once the locale base API is refactored
# UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
-# TODO: Fix seemingly circular inclusion or <wchar.h> on AIX
-# UNSUPPORTED: LIBCXX-AIX-FIXME
# UNSUPPORTED: FROZEN-CXX03-HEADERS-FIXME
More information about the libcxx-commits
mailing list