Jelajahi Sumber

Merge pull request #6970 from StephanTLavavej/stringize

Avoid using MSVC-internal `_STRINGIZE`
Petr Penzin 1 tahun lalu
induk
melakukan
13358c622f
3 mengubah file dengan 22 tambahan dan 11 penghapusan
  1. 7 1
      bin/NativeTests/stdafx.h
  2. 5 5
      bin/ch/stdafx.h
  3. 10 5
      pal/inc/assert_only.h

+ 7 - 1
bin/NativeTests/stdafx.h

@@ -1,5 +1,6 @@
 //-------------------------------------------------------------------------------------------------------
 // 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.
 //-------------------------------------------------------------------------------------------------------
 
@@ -25,11 +26,16 @@
 
 #define DebugOnly(x)          x
 
+#if !defined(CHAKRACORE_STRINGIZE)
+#define CHAKRACORE_STRINGIZE_IMPL(x) #x
+#define CHAKRACORE_STRINGIZE(x) CHAKRACORE_STRINGIZE_IMPL(x)
+#endif
+
 #define AssertMsg(exp, comment)   \
 do { \
 if (!(exp)) \
 { \
-    fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, _STRINGIZE(exp), comment); \
+    fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, CHAKRACORE_STRINGIZE(exp), comment); \
     fflush(stderr); \
     DebugBreak(); \
 } \

+ 5 - 5
bin/ch/stdafx.h

@@ -1,6 +1,6 @@
 //-------------------------------------------------------------------------------------------------------
 // Copyright (C) Microsoft. All rights reserved.
-// Copyright (c) 2021 ChakraCore Project Contributors. 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
@@ -57,16 +57,16 @@
 
 #if defined(DBG)
 
-#define _STRINGIZE_(x) #x
-#if !defined(_STRINGIZE)
-#define _STRINGIZE(x) _STRINGIZE_(x)
+#if !defined(CHAKRACORE_STRINGIZE)
+#define CHAKRACORE_STRINGIZE_IMPL(x) #x
+#define CHAKRACORE_STRINGIZE(x) CHAKRACORE_STRINGIZE_IMPL(x)
 #endif
 
 #define AssertMsg(exp, comment)   \
 do { \
 if (!(exp)) \
 { \
-    fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, _STRINGIZE(exp), comment); \
+    fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, CHAKRACORE_STRINGIZE(exp), comment); \
     fflush(stderr); \
     DebugBreak(); \
 } \

+ 10 - 5
pal/inc/assert_only.h

@@ -1,25 +1,30 @@
 //-------------------------------------------------------------------------------------------------------
-// Copyright (C) Microsoft. All rights reserved.
+// ChakraCore/Pal
+// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
+// and edits (c) copyright the ChakraCore Contributors.
+// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 
 // PAL free Assert definitions
 #ifdef DEBUG
 
-#define _QUOTE_(s) #s
-#define _STRINGIZE_(s) _QUOTE_(s)
+#if !defined(CHAKRACORE_STRINGIZE)
+#define CHAKRACORE_STRINGIZE_IMPL(x) #x
+#define CHAKRACORE_STRINGIZE(x) CHAKRACORE_STRINGIZE_IMPL(x)
+#endif
 
 #ifndef __ANDROID__
 #define _ERR_OUTPUT_(condition, comment) \
     fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, \
-      _STRINGIZE_(condition), comment); \
+      CHAKRACORE_STRINGIZE(condition), comment); \
     fflush(stderr);
 #else // ANDROID
 #include <android/log.h>
 #define _ERR_OUTPUT_(condition, comment) \
     __android_log_print(ANDROID_LOG_ERROR, "chakracore-log", \
       "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, \
-      _STRINGIZE_(condition), comment);
+      CHAKRACORE_STRINGIZE(condition), comment);
 #endif
 
 #define _Assert_(condition, comment)   \