在 2026-3-18 03:45, Pali Rohár 写道:
When mingw-w64 switched the default build from msvcrt to UCRT, it also
switched swprintf %S from wchar_t* to char* because it switched from
mingw-w64 printf to MS printf implementation. This already happened in
the past and I did not found reported issues about it related to %Č and
%S formats.

My change here affects only non-default mingw-w64 builds (msvcrt) or
when compiling applications with additional -D flags.

IMHO bigger risk was the %S change which happened in the past for
default builds than this my change.


Anyway, msvc supports _CRT_STDIO_ISO_WIDE_SPECIFIERS and
_CRT_STDIO_LEGACY_WIDE_SPECIFIERS defines which explicitly choose the
behavior of %S / %C formats. Maybe we can extend the mingw-w64 header
files via asm forward directive to also support these macros and
redirect to functions with char* vs wchar_t* support.


One thing that you should be aware of is that libstdc++ defines `__USE_MINGW_ANSI_STDIO` unconditionally [1]. This means that mostly all existent C++ code has been calling mingw-w64 *printf functions since 15 years ago, and C++ is far more widely used than C.


In order to evaluate such a change, we need some statistics about what existing code passes to `wprintf()` for `const char*`, such as [2] from GitHub Copilot:

   Approximate ranking from this sample
   From the returned examples I could inspect, the observed ordering is roughly:

   1. L"%s" — most common
   2. L"%S" — second
   3. L"%hs" — third
   4. L"%ls" for const char* — effectively absent in this sample

... which does not look like an affirmative response.


[1]: https://github.com/gcc-mirror/gcc/blob/7d70ce4e9a0244a2585a4bf1a9205bfb0443cc2e/libstdc%2B%2B-v3/config/os/mingw32-w64/os_defines.h#L47-L51
[2]: https://github.com/copilot/c/8bbea74e-1494-4c46-94c5-84b80f2e0323




--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to