On Wednesday 25 June 2025 22:06:22 LIU Hao wrote:
> 在 2025-6-25 06:29, Pali Rohár 写道:
> > Format %c and %s when used in some wide wprintf function takes the wide
> > wchar_t char or wide wchar_t* string. This is msvcrt.dll and UCRT behavior.
> > 
> > This change aligns the mingw-w64 wprintf functions to be compatible with MS.
> > ---
> >   mingw-w64-crt/stdio/mingw_pformat.c | 12 ++++++++++--
> >   1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> 
> The mingw-w64 printf functions have C99 behavior for many years. Given the
> quantity of users who have been used to that, I don't think there's enough
> reason to make a change.

That is a valid point and I would understand if these changes would not
be accepted. That makes sense.

But I would like to point out that we have already this ms vs c99
inconsistency between msvcrt and ucrt builds. And something should be
improved here.

When -std=c99 is specified then for msvcrt is used the C99 behavior and
for UCRT is used ms behavior. That is because -std=c99 for msvcrt uses
mingw-w64 printf and for UCRT it uses printf from ucrt library which is
not c99 compatible.

I do not think that having this inconsistency is a good idea.

One proposal from my side: Add support for UCRT compile time macros
_CRT_STDIO_ISO_WIDE_SPECIFIERS and _CRT_STDIO_LEGACY_WIDE_SPECIFIERS
by which application can decide if wants C99 behavior or MS behavior.

We can provide two mingw-w64 wide print functions and our stdio.h can
redirect via __MINGW_ASM_CALL() to correct function based on those
macros.

And maybe we can predefine _CRT_STDIO_ISO_WIDE_SPECIFIERS if the
-std=c99 or -std=c11 or new is explicitly specified when application or
user wants ISO C compliant behavior.

For example there are some "features" of ISO C lang (e.g. digraphs)
which are not enabled by -std=gnu99, but are enabled by -std=c99.
Maybe we can do similar thing for wide printf functions? Just an idea.

> 
> > Format %c and %s when used in some wide wprintf function takes the wide
>                    \-------------------------------------/
>   \-------v------/                                           ^
>            \------------------------------------------------/
> 
> nitpicking:                                                take
> 
> 
> 
> -- 
> Best regards,
> LIU Hao


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to