chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.06k stars 1.19k forks source link

Avoid using MSVC-internal `_STRINGIZE` #6970

Closed StephanTLavavej closed 1 day ago

StephanTLavavej commented 3 months ago

I work on Microsoft's C++ Standard Library implementation, where we recently merged microsoft/STL#4405 to remove our internal _STRINGIZE macro. Our "Real World Code" test suite, which builds popular open-source projects like yours, found that you were using this MSVC-internal macro and therefore our change broke your code.

The C++ Standard's rule is that _Leading_underscore_capital identifiers (including _LEADING_UNDERSCORE_ALL_CAPS) are reserved for the compiler and Standard Library, so other libraries and applications should avoid using such reserved identifiers. This is N4971 5.10 [lex.name]/3:

In addition, some identifiers appearing as a token or preprocessing-token are reserved for use by C++ implementations and shall not be used otherwise; no diagnostic is required. — Each identifier that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use.

This PR introduces non-reserved names that will work on all platforms.

rhuanjl commented 2 months ago

Hi @StephanTLavavej thank you for the heads up about this pending breakage.

Looking at the code it looks to me like only bin/NativeTests/stdafx.h would be broken and the other two instances whilst using a similar name already defined alternative macros; is that correct? Did you rename the others for consistency?

StephanTLavavej commented 2 months ago

Yes, I renamed them to consistently follow the Standard's rules for reserved identifiers, and to make it easier to verify that there are no remaining dependencies on microsoft/STL's removed macro.