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

Unify stringification macros #4405

Merged
merged 3 commits into from
Feb 27, 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
2 changes: 1 addition & 1 deletion stl/inc/use_ansi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define _LIB_STEM "libcpmt"

#if _ITERATOR_DEBUG_LEVEL != _IDL_DEFAULT
#define _IDL_AFFIX _STRINGIZE(_ITERATOR_DEBUG_LEVEL)
#define _IDL_AFFIX _STL_STRINGIZE(_ITERATOR_DEBUG_LEVEL)
#endif // _ITERATOR_DEBUG_LEVEL != _IDL_DEFAULT
#endif // ^^^ !defined(_DLL) || defined(_STATIC_CPPLIB) ^^^

Expand Down
2 changes: 1 addition & 1 deletion stl/inc/yvals.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ _STL_DISABLE_CLANG_WARNINGS
#endif // !defined(_ALLOW_MSC_VER_MISMATCH)

#ifndef _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
#pragma detect_mismatch("_ITERATOR_DEBUG_LEVEL", _STRINGIZE(_ITERATOR_DEBUG_LEVEL))
#pragma detect_mismatch("_ITERATOR_DEBUG_LEVEL", _STL_STRINGIZE(_ITERATOR_DEBUG_LEVEL))
#endif // !defined(_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH)

#ifndef _ALLOW_RUNTIME_LIBRARY_MISMATCH
Expand Down
8 changes: 2 additions & 6 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
#if _STL_COMPILER_PREPROCESSOR

// This does not use `_EMIT_STL_ERROR`, as it needs to be checked before we include anything else.
// However, `_EMIT_STL_ERROR` has a dependency on `_CRT_STRINGIZE`, defined in `<vcruntime.h>`.
// Here, we employ the same technique as `_CRT_STRINGIZE` in order to avoid needing to update the line number.
#ifndef __cplusplus
#define _STL_STRINGIZE_(S) #S
#define _STL_STRINGIZE(S) _STL_STRINGIZE_(S)
#ifndef __cplusplus
#pragma message(__FILE__ "(" _STL_STRINGIZE(__LINE__) "): STL1003: Unexpected compiler, expected C++ compiler.")
#error Error in C++ Standard Library usage
#endif // !defined(__cplusplus)
Expand Down Expand Up @@ -515,7 +513,7 @@
#endif

#define _STL_PRAGMA_MESSAGE(MESSAGE) _STL_PRAGMA(message(MESSAGE))
#define _EMIT_STL_MESSAGE(MESSAGE) _STL_PRAGMA_MESSAGE(__FILE__ "(" _CRT_STRINGIZE(__LINE__) "): " MESSAGE)
#define _EMIT_STL_MESSAGE(MESSAGE) _STL_PRAGMA_MESSAGE(__FILE__ "(" _STL_STRINGIZE(__LINE__) "): " MESSAGE)

#define _EMIT_STL_WARNING(NUMBER, MESSAGE) _EMIT_STL_MESSAGE("warning " #NUMBER ": " MESSAGE)
#define _EMIT_STL_ERROR(NUMBER, MESSAGE) static_assert(false, "error " #NUMBER ": " MESSAGE)
Expand Down Expand Up @@ -1917,8 +1915,6 @@ compiler option, or define _ALLOW_RTCc_IN_STL to suppress this error.
#endif // !defined(_ALLOW_RTCc_IN_STL)
#endif // defined(_RTC_CONVERSION_CHECKS_ENABLED)

#define _STRINGIZEX(x) #x
#define _STRINGIZE(x) _STRINGIZEX(x)
#define _EMPTY_ARGUMENT // for empty macro argument

// extern "C++" attaches declarations to the global module, see N4964 [module.unit]/7.2.
Expand Down