Skip to content

Commit

Permalink
Unify stringification macros (#4405)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsb4000 authored Feb 27, 2024
1 parent b31e883 commit 9c63696
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
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

0 comments on commit 9c63696

Please sign in to comment.