Skip to content

Commit 13358c6

Browse files
authored
Merge pull request #6970 from StephanTLavavej/stringize
Avoid using MSVC-internal `_STRINGIZE`
2 parents 3a7b120 + 3998959 commit 13358c6

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

bin/NativeTests/stdafx.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3+
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56

@@ -25,11 +26,16 @@
2526

2627
#define DebugOnly(x) x
2728

29+
#if !defined(CHAKRACORE_STRINGIZE)
30+
#define CHAKRACORE_STRINGIZE_IMPL(x) #x
31+
#define CHAKRACORE_STRINGIZE(x) CHAKRACORE_STRINGIZE_IMPL(x)
32+
#endif
33+
2834
#define AssertMsg(exp, comment) \
2935
do { \
3036
if (!(exp)) \
3137
{ \
32-
fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, _STRINGIZE(exp), comment); \
38+
fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, CHAKRACORE_STRINGIZE(exp), comment); \
3339
fflush(stderr); \
3440
DebugBreak(); \
3541
} \

bin/ch/stdafx.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
22
// Copyright (C) Microsoft. All rights reserved.
3-
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
3+
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
44
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
55
//-------------------------------------------------------------------------------------------------------
66
#pragma once
@@ -57,16 +57,16 @@
5757

5858
#if defined(DBG)
5959

60-
#define _STRINGIZE_(x) #x
61-
#if !defined(_STRINGIZE)
62-
#define _STRINGIZE(x) _STRINGIZE_(x)
60+
#if !defined(CHAKRACORE_STRINGIZE)
61+
#define CHAKRACORE_STRINGIZE_IMPL(x) #x
62+
#define CHAKRACORE_STRINGIZE(x) CHAKRACORE_STRINGIZE_IMPL(x)
6363
#endif
6464

6565
#define AssertMsg(exp, comment) \
6666
do { \
6767
if (!(exp)) \
6868
{ \
69-
fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, _STRINGIZE(exp), comment); \
69+
fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, CHAKRACORE_STRINGIZE(exp), comment); \
7070
fflush(stderr); \
7171
DebugBreak(); \
7272
} \

pal/inc/assert_only.h

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
//-------------------------------------------------------------------------------------------------------
2-
// Copyright (C) Microsoft. All rights reserved.
2+
// ChakraCore/Pal
3+
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
4+
// and edits (c) copyright the ChakraCore Contributors.
5+
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
36
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
47
//-------------------------------------------------------------------------------------------------------
58

69
// PAL free Assert definitions
710
#ifdef DEBUG
811

9-
#define _QUOTE_(s) #s
10-
#define _STRINGIZE_(s) _QUOTE_(s)
12+
#if !defined(CHAKRACORE_STRINGIZE)
13+
#define CHAKRACORE_STRINGIZE_IMPL(x) #x
14+
#define CHAKRACORE_STRINGIZE(x) CHAKRACORE_STRINGIZE_IMPL(x)
15+
#endif
1116

1217
#ifndef __ANDROID__
1318
#define _ERR_OUTPUT_(condition, comment) \
1419
fprintf(stderr, "ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, \
15-
_STRINGIZE_(condition), comment); \
20+
CHAKRACORE_STRINGIZE(condition), comment); \
1621
fflush(stderr);
1722
#else // ANDROID
1823
#include <android/log.h>
1924
#define _ERR_OUTPUT_(condition, comment) \
2025
__android_log_print(ANDROID_LOG_ERROR, "chakracore-log", \
2126
"ASSERTION (%s, line %d) %s %s\n", __FILE__, __LINE__, \
22-
_STRINGIZE_(condition), comment);
27+
CHAKRACORE_STRINGIZE(condition), comment);
2328
#endif
2429

2530
#define _Assert_(condition, comment) \

0 commit comments

Comments
 (0)