[libc-commits] [libc] [libc] Do not redefine `wchar_t` when compiling in C++ (PR #110769)

via libc-commits libc-commits at lists.llvm.org
Tue Oct 1 17:04:51 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
This is a fundamental type in C++, so we can't redefine it.


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


1 Files Affected:

- (modified) libc/include/llvm-libc-types/wchar_t.h (+5) 


``````````diff
diff --git a/libc/include/llvm-libc-types/wchar_t.h b/libc/include/llvm-libc-types/wchar_t.h
index faa40d96efc4d2..bf2633a1c244bf 100644
--- a/libc/include/llvm-libc-types/wchar_t.h
+++ b/libc/include/llvm-libc-types/wchar_t.h
@@ -9,6 +9,11 @@
 #ifndef LLVM_LIBC_TYPES_WCHAR_T_H
 #define LLVM_LIBC_TYPES_WCHAR_T_H
 
+// wchar_t is a fundamental type in C++.
+#ifndef __cplusplus
+
 typedef __WCHAR_TYPE__ wchar_t;
 
+#endif
+
 #endif // LLVM_LIBC_TYPES_WCHAR_T_H

``````````

</details>


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


More information about the libc-commits mailing list