[libc-commits] [libc] [libc] Always provide char8/16/32_t (PR #143803)

via libc-commits libc-commits at lists.llvm.org
Wed Jun 11 16:05:23 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/143803.diff


3 Files Affected:

- (modified) libc/include/llvm-libc-types/char16_t.h (-2) 
- (modified) libc/include/llvm-libc-types/char32_t.h (-2) 
- (modified) libc/include/llvm-libc-types/char8_t.h (+1-2) 


``````````diff
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
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/143803


More information about the libc-commits mailing list