[libc-commits] [libc] [libc] Fix char8_t public and proxy headers. (PR #220352)
via libc-commits
libc-commits at lists.llvm.org
Tue Sep 1 12:58:08 PDT 2026
https://github.com/lntue updated https://github.com/llvm/llvm-project/pull/220352
>From 7622485e953e7ad4483ffb8b49925f8791322e4b Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Tue, 1 Sep 2026 19:40:49 +0000
Subject: [PATCH 1/2] [libc] Fix char8_t public and proxy headers.
---
libc/hdr/types/char8_t.h | 19 +++++++++++++++++++
libc/include/llvm-libc-types/char8_t.h | 4 ++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/libc/hdr/types/char8_t.h b/libc/hdr/types/char8_t.h
index 4d71e3dd89098..2ec50162ede4a 100644
--- a/libc/hdr/types/char8_t.h
+++ b/libc/hdr/types/char8_t.h
@@ -9,6 +9,25 @@
#ifndef LLVM_LIBC_HDR_TYPES_CHAR8_T_H
#define LLVM_LIBC_HDR_TYPES_CHAR8_T_H
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/char8_t.h"
+
+#else // Overlay mode
+
+// MacOS doesn't provide uchar.h so we use the types provided by LLVM-libc.
+#ifdef __APPLE__
#include "include/llvm-libc-types/char8_t.h"
+#else
+#include "hdr/uchar_overlay.h"
+#endif
+
+// Define char8_t in C++ for internal usage if it is not provided by compiler
+// or system uchar.h header.
+#ifndef __cpp_char8_t
+using char8_t = unsigned char;
+#endif // !__cpp_char8_t
+
+#endif // LIBC_FULL_BUILD
#endif // LLVM_LIBC_HDR_TYPES_CHAR8_T_H
diff --git a/libc/include/llvm-libc-types/char8_t.h b/libc/include/llvm-libc-types/char8_t.h
index a343be77d810b..6c12127601727 100644
--- a/libc/include/llvm-libc-types/char8_t.h
+++ b/libc/include/llvm-libc-types/char8_t.h
@@ -9,8 +9,8 @@
#ifndef LLVM_LIBC_TYPES_CHAR8_T_H
#define LLVM_LIBC_TYPES_CHAR8_T_H
-#if !(defined(__cplusplus) && defined(__cpp_char8_t))
+#ifndef __cpp_char8_t
typedef unsigned char char8_t;
-#endif
+#endif // !__cpp_char8_t
#endif // LLVM_LIBC_TYPES_CHAR8_T_H
>From 509a28ecd41bfdcfc2899422b00fb02468c6f251 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Tue, 1 Sep 2026 19:57:37 +0000
Subject: [PATCH 2/2] Address commments.
---
libc/hdr/types/char8_t.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libc/hdr/types/char8_t.h b/libc/hdr/types/char8_t.h
index 2ec50162ede4a..76334b338cf29 100644
--- a/libc/hdr/types/char8_t.h
+++ b/libc/hdr/types/char8_t.h
@@ -16,11 +16,9 @@
#else // Overlay mode
// MacOS doesn't provide uchar.h so we use the types provided by LLVM-libc.
-#ifdef __APPLE__
-#include "include/llvm-libc-types/char8_t.h"
-#else
+#ifndef __APPLE__
#include "hdr/uchar_overlay.h"
-#endif
+#endif // !__APPLE__
// Define char8_t in C++ for internal usage if it is not provided by compiler
// or system uchar.h header.
More information about the libc-commits
mailing list