Ver código fonte

Alternative fix for unicode errors

Include system headers that may cause to PAL_* macros to
get undefined early in pal.h.
Ivan Krasilnikov 2 meses atrás
pai
commit
0c6b0cdc4a
2 arquivos alterados com 12 adições e 15 exclusões
  1. 0 15
      lib/Runtime/PlatformAgnostic/ChakraICU.h
  2. 12 0
      pal/inc/pal.h

+ 0 - 15
lib/Runtime/PlatformAgnostic/ChakraICU.h

@@ -1,6 +1,5 @@
 //-------------------------------------------------------------------------------------------------------
 // Copyright (C) Microsoft. All rights reserved.
-// Copyright (c) ChakraCore Project Contributors. All rights reserved.
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #pragma once
@@ -47,20 +46,6 @@
 #include "unicode/upluralrules.h"
 #endif // ifdef WINDOWS10_ICU
 
-// Use PAL wrappers for Linux arm64 to fix wchar_t/char16_t mismatches.
-// Cannot go before system unicode headers - here is the earliest
-// possible point to override these.
-#if defined(_ARM64_) && defined(__linux__)
-#define wcschr  PAL_wcschr
-#define wcscmp  PAL_wcscmp
-#define wcslen  PAL_wcslen
-#define wcsncmp PAL_wcsncmp
-#define wcsrchr PAL_wcsrchr
-#define wcsstr  PAL_wcsstr
-#define wmemcmp PAL_wmemcmp
-#define wprintf PAL_wprintf
-#endif
-
 // Different assertion code is used in ChakraFull that enforces that messages are char literals
 #ifdef _CHAKRACOREBUILD
 #define ICU_ERRORMESSAGE(e) u_errorName(e)

+ 12 - 0
pal/inc/pal.h

@@ -49,6 +49,18 @@ Abstract:
 #include <ctype.h>
 #endif
 
+// On some Linux distros, these system headers and their dependencies
+// (included through unicode headers in ChakraICU.h during ICU-enabled
+// builds in particular) contain macros like `#undef wcslen`, which
+// conflict with our PAL_* macros. As a workaround, include these system
+// headers early in front of our PAL_* definitions, so that when they
+// are included again later on, they would not undefine our macros.
+#if defined(PLATFORM_UNIX) && defined(HAS_ICU) && defined(PAL_STDCPP_COMPAT) && __cplusplus >= 201703L
+#include <cwchar>
+#include <string>
+#include <string_view>
+#endif
+
 #if !defined(static_assert)
 #define static_assert _Static_assert
 #endif