On Sat, 22 Feb 2020, Dan Raymond wrote:
The latter change raises a new issue because _vscprintf is not present
in the VC6 C-runtime library. The VC6 APIs are the only ones in
msvcrt.dll that we can rely on according to these blogs:
https://devblogs.microsoft.com/oldnewthing/20140411-00/?p=1273
https://sourceforge.net/p/mingw-w64/wiki2/The%20case%20against%20msvcrt.dll/
The VC6 APIs in msvcrt.dll are safe to use because applications compiled
using VC6 and earlier rely on them. MSFT can't remove those APIs or
make backwards incompatible changes to them or it will break those
applications. All APIs added to msvcrt.dll after VC6, however, were
intended for internal use by Windows itself. That includes _vscprintf.
Those APIs can be removed or altered by MSFT at any time. If MinGW uses
them every application compiled with MinGW is at risk of breaking every
time a Windows Update occurs.
Yes, one shouldn't use functions outside of that subset, or ideally not
link against msvcrt.dll at all. The proper solution to this is to use UCRT
instead - this is now possible since a few years.
I'm fairly sure that we rely on a number of functions outside of the VC6
subset even before this patch (no I can't list the cases off-hand). And
restricting things to that subset isn't really an option - if we wouldn't
need to use such functions, we wouldn't. Especially for simplifying
compatibility between msvcrt.dll and UCRT, we've been refactoring things
and using a bit newer functions in a few places, if I remember correctly.
Even if Microsoft _could_ ship an update to msvcrt.dll where they wildly
change the existing behaviour to any of the functions outside of the VC6
subset that we might be using, chances are that they won't.
So in practice, we rely on whatever features of msvcrt.dll that are
available and have a stable behaviour from XP throughout versions up to
Win10. While we can't know for sure they won't change in the future, it's
a risk I think we're willing to take. The only proper solution long term
is to switch to the UCRT.
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public