From e99e185712bc19b969dcc0f9db5557234c7be25e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 2 Nov 2020 09:32:06 +0900 Subject: [PATCH] Don't typedef wchar_t for C++ wchar_t is a builtin type in C++. clang complains like the following even with -fshort-wchar: error: cannot combine with previous 'type-name' declaration specifier my clang version if it matters: spacetanuki% clang++ --version Apple clang version 11.0.0 (clang-1100.0.33.17) Target: x86_64-apple-darwin18.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin spacetanuki% clang++ -dM -E - < /dev/null | grep WCHAR #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_WCHAR_T__ 4 #define __WCHAR_MAX__ 2147483647 #define __WCHAR_TYPE__ int #define __WCHAR_WIDTH__ 32 spacetanuki% clang++ -fshort-wchar -dM -E - < /dev/null | grep WCHAR #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_WCHAR_T__ 2 #define __WCHAR_MAX__ 65535 #define __WCHAR_TYPE__ unsigned short #define __WCHAR_UNSIGNED__ 1 #define __WCHAR_WIDTH__ 16 spacetanuki% --- include/sys/types.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/sys/types.h b/include/sys/types.h index b55c9b320f4..4bc7b97045a 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -178,10 +178,9 @@ typedef int16_t key_t; typedef intptr_t ptrdiff_t; -#ifndef CONFIG_WCHAR_BUILTIN +#if !defined(__cplusplus) /* Wide, 16-bit character types. wchar_t is a built-in type in C++ and - * its declaration here may cause compilation errors on some compilers - * if -DCONFIG_WCHAR_BUILTIN is not included in the CXXFLAGS. + * its declaration here may cause compilation errors on some compilers. * * REVISIT: wchar_t belongs in stddef.h */