Skip to content

Commit

Permalink
Avoid using MSVC-internal _STRINGIZE.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored and ppenzin committed Jul 3, 2024
1 parent 3a7b120 commit 3998959
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
8 changes: 7 additions & 1 deletion bin/NativeTests/stdafx.h
Original file line number Diff line number Diff line change
@@ -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.
//-------------------------------------------------------------------------------------------------------

Expand All @@ -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(); \
} \
Expand Down
10 changes: 5 additions & 5 deletions bin/ch/stdafx.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(); \
} \
Expand Down
15 changes: 10 additions & 5 deletions pal/inc/assert_only.h
Original file line number Diff line number Diff line change
@@ -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) \
Expand Down

0 comments on commit 3998959

Please sign in to comment.