1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
15 This file is used to define the wchar_t type as a 16-bit type on Unix.
21 // The unix compilers use a 32-bit wchar_t, so we must make a 16 bit wchar_t.
22 // The windows compilers, gcc and MSVC, both define a 16 bit wchar_t.
24 // Note : wchar_t is a built-in type in C++, gcc/llvm ignores any attempts to
25 // typedef it. Using the preprocessor here, we make sure gcc sees
26 // __wchar_16_cpp__ instead of wchar_t. This is apparently not necessary under
27 // vc++, for whom wchar_t is already a typedef instead of a built-in.
29 #ifndef PAL_STDCPP_COMPAT
32 #define __WCHAR_TYPE__ __wchar_16_cpp__
33 #define wchar_t __wchar_16_cpp__
35 // Set up the wchar_t type (which got preprocessed to __wchar_16_cpp__).
36 // In C++11, the standard gives us char16_t, which is what we want (and matches types with u"")
37 // In C, this doesn't exist, so use unsigned short.
38 // **** WARNING: Linking C and C++ objects will break with -fstrict-aliasing with GCC/Clang
39 // due to conditional typedef
40 #if !defined(_WCHAR_T_DEFINED) || !defined(_MSC_VER)
41 #if defined(__cplusplus)
43 #define __WCHAR_TYPE__ char16_t
44 typedef char16_t wchar_t;
47 #define __WCHAR_TYPE__ unsigned short
48 typedef unsigned short wchar_t;
51 #ifndef _WCHAR_T_DEFINED
52 #define _WCHAR_T_DEFINED
53 #endif // !_WCHAR_T_DEFINED
54 #endif // !_WCHAR_T_DEFINED || !_MSC_VER
55 #endif // !PAL_STDCPP_COMPAT