Skip to content

Conversation

@michaelrj-google
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented Jun 11, 2025

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

Changes

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants