[libc-commits] [libc] [libc] Always provide char8/16/32_t (PR #143803)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed Jun 11 16:04:56 PDT 2025
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/143803
The current definitions only provide these types if the stdc version is
2023 for char8_t or 2011 for char16/32_t. None of our other types are
currently handled this way. If we want to provide these headers only
under certain circumstances we should add guards to the types in the
public header, since internal code should always have access to these
types.
>From 6adb80d86101268ea7791b6a43e96b5605d66612 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Wed, 11 Jun 2025 16:01:51 -0700
Subject: [PATCH] [libc] Always provide char8/16/32_t
The current definitions only provide these types if the stdc version is
2023 for char8_t or 2011 for char16/32_t. None of our other types are
currently handled this way. If we want to provide these headers only
under certain circumstances we should add guards to the types in the
public header, since internal code should always have access to these
types.
---
libc/include/llvm-libc-types/char16_t.h | 2 --
libc/include/llvm-libc-types/char32_t.h | 2 --
libc/include/llvm-libc-types/char8_t.h | 3 +--
3 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/libc/include/llvm-libc-types/char16_t.h b/libc/include/llvm-libc-types/char16_t.h
index 1f5847ae771b4..1d6e9f98cf886 100644
--- a/libc/include/llvm-libc-types/char16_t.h
+++ b/libc/include/llvm-libc-types/char16_t.h
@@ -9,9 +9,7 @@
#ifndef LLVM_LIBC_TYPES_CHAR16_T_H
#define LLVM_LIBC_TYPES_CHAR16_T_H
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#include "../llvm-libc-macros/stdint-macros.h"
typedef uint_least16_t char16_t;
-#endif
#endif // LLVM_LIBC_TYPES_CHAR16_T_H
diff --git a/libc/include/llvm-libc-types/char32_t.h b/libc/include/llvm-libc-types/char32_t.h
index 20b72dc5d67e3..24b5ef52badfd 100644
--- a/libc/include/llvm-libc-types/char32_t.h
+++ b/libc/include/llvm-libc-types/char32_t.h
@@ -9,9 +9,7 @@
#ifndef LLVM_LIBC_TYPES_CHAR32_T_H
#define LLVM_LIBC_TYPES_CHAR32_T_H
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#include "../llvm-libc-macros/stdint-macros.h"
typedef uint_least32_t char32_t;
-#endif
#endif // LLVM_LIBC_TYPES_CHAR32_T_H
diff --git a/libc/include/llvm-libc-types/char8_t.h b/libc/include/llvm-libc-types/char8_t.h
index ddadab1afa219..a343be77d810b 100644
--- a/libc/include/llvm-libc-types/char8_t.h
+++ b/libc/include/llvm-libc-types/char8_t.h
@@ -9,8 +9,7 @@
#ifndef LLVM_LIBC_TYPES_CHAR8_T_H
#define LLVM_LIBC_TYPES_CHAR8_T_H
-#if !defined(__cplusplus) && defined(__STDC_VERSION__) && \
- __STDC_VERSION__ >= 202311L
+#if !(defined(__cplusplus) && defined(__cpp_char8_t))
typedef unsigned char char8_t;
#endif
More information about the libc-commits
mailing list