On Thu, 28 Nov 2024, Pali Rohár wrote:
In commit 797b4a6b5191 ("headers: Expose the wchar ctype _l functions for msvcrt.dll for Vista") was added following pattern:#if __MSVCRT_VERSION__ >= 0x800 || (__MSVCRT_VERSION__ == 0x700 && _WIN32_WINNT >= 0x0600) /* These are available since msvcr80.dll, and in msvcrt.dll since Vista. */ _CRTIMP int __cdecl _iswalpha_l(wint_t _C,_locale_t _Locale); ... #endif This preprocessor condition is not fully correct as it matches also the case when compiling for msvcr70.dll library on Windows Vista+ target systems. msvcr70.dll library does not provide these ctype _l functions on Windows Vista or new systems. So it should not be enabled. The problem is that currently __MSVCRT_VERSION__ == 0x700 condition means compiling for msvcrt.dll OR for msvcr70.dll. And currently it is not possible to distinguish between these two targets. Fix this problem by changing the __MSVCRT_VERSION__ value when compiling for msvcrt.dll and set __MSVCRT_VERSION__ to 0x600. This is logical step because msvcrt.dll provides ABI / DLL library name of the Visual C++ 6.0 version and msvcr70.dll provides ABI / DLL library name of the Visual Studio 2002 (AKA VC++ 7.0). msvcrt.dll preinstalled as part of the Windows system provides more functions than the original Visual C++ 6.0, but still it is compatible with the original version. So setting __MSVCRT_VERSION__ to 0x600 for msvcrt.dll build is relatively sane option. I was considering to use 0x6FF value for this case, but this would make it more complicated for applications if they need to know if they are being compiled for msvcrt.dll library ABI. They would need to check if the macro __MSVCRT_VERSION__ is set to 0x600 (targetting the original VC++ msvcrt.dll library) or to value 0x6FFF (targettting the system msvcrt.dll library). This looks to be additional complication as it would be needed to track all possible values for __MSVCRT_VERSION__. So using just one value 0x600 for both cases should be enough because for system version specific version is always needed to check also _WIN32_WINNT value.
I think this change looks reasonable to me, but I'd like Liu Hao, who suggested the 0x6FF version, to follow up here.
// Martin _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
