On Wed, 25 Jun 2025, Pali Rohár wrote:

On Wednesday 25 June 2025 23:04:58 Martin Storsjö wrote:
On Wed, 25 Jun 2025, Pali Rohár wrote:

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.

It would indeed be nice if we could make this work, somehow. We do have the
mechanism for setting the options for the UCRT stdio functions, since
3f5c5d854234971909e86d03a8351494db68f615 - but setting it up to react to
these macros is a bit trickier.

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.

No, I don't think we should do that.

One core target, at least for me, is that we use the CRT's printfs by
default, at least in UCRT mode.

On a higher level, I want us to statically link less code into our binaries,
not more.

UCRT printf functions have flags which specify in what kind of mode the
function should work.

So we can use UCRT printf function with proper flags to work also in C99
mode. Just it is needed to write a small wrapper for it, either as
static inline function or as external function. If it is as static
inline function, we can use #ifdef based on _CRT_STDIO_ISO_WIDE_SPECIFIERS
and _CRT_STDIO_LEGACY_WIDE_SPECIFIERS. If it would be small external
function then it can be redirected via __MINGW_ASM_CALL.

This would end up duplicating every single stdio function again, for a separate version to set different flags. I don't want us to duplicate every single function yet again.

In MSVC, _CRT_STDIO_ISO_WIDE_SPECIFIERS or _CRT_STDIO_LEGACY_WIDE_SPECIFIERS set the per-DLL/EXE global stdio flags - I'd rather try to do that, than duplicate every function.

So I'd rather have this use the UCRT stdio setting mechanism, somehow (I
don't know offhand how), not make it switch back to the mingw statically
linked printfs.

// Martin

Ok, that is the UCRT part. And how to solve it with msvcrt builds?

We don't. We just leave it as it is.

// Martin

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

Reply via email to