From c6fd07cdecce8fc3a517258d5145e89cd2781a9b Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Fri, 22 Nov 2019 21:44:57 +1100 Subject: [PATCH] ICU-20904 Don't use char16_t with C++98/03 When C code includes the ICU headers, the UChar type is defined to be uint16_t. But when C++ code includes the headers, UChar is char16_t even when U_SHOW_CPLUSPLUS_API has been set to 0. Apart from arguably being an inconsistency in the API, this means that C++98 or C++03 code can't use the C API even though C99 code can. So, change unicode/umachine.h to check not just whether __cplusplus is defined but the value of U_CPLUSPLUS_VERSION when deciding how to typedef UChar. --- icu4c/source/common/unicode/umachine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icu4c/source/common/unicode/umachine.h b/icu4c/source/common/unicode/umachine.h index c52984cef39..1d85855ac9d 100644 --- a/icu4c/source/common/unicode/umachine.h +++ b/icu4c/source/common/unicode/umachine.h @@ -372,7 +372,7 @@ typedef int8_t UBool; typedef char16_t UChar; #elif defined(UCHAR_TYPE) typedef UCHAR_TYPE UChar; -#elif defined(__cplusplus) +#elif (U_CPLUSPLUS_VERSION >= 11) typedef char16_t UChar; #else typedef uint16_t UChar; -- 2.40.0