Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using MSVC-internal _STRINGIZE #6970

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading