在 2024-11-12 11:55, sisyphus 写道:
If I want to configure the gmp library to be built with HAVE_VSNPRINTF defined, and I'm using a UCRT compiler package, then I need to configure with the -D__USE_MINGW_ANSI_STDIO flag. (Otherwise the gmp configure step decides that vsnprintf does not work, and an mpfr library built against the resultant gmp library exhibits some buggy behaviour.)But if I'm using an MSVCRT compiler package, then there's no need to specify that flag.
I think it's because of this: https://github.com/mingw-w64/mingw-w64/blob/a0f68282b1fb5d2490e2fef052306ed9542e9962/mingw-w64-headers/crt/_mingw.h.in#L422
Is that difference to be expected? Or is it indicative of some oversight, somewhere?
Yes. The decision for defining `__USE_MINGW_ANSI_STDIO` for MSVCRT was that there should be a simple way to print a `long long`, but `%lld` only works with Vista MSVCRT and not XP MSVCRT.
As for UCRT, Microsoft claim that 'the `vsnprintf` function 'conforms to the C99 standard' [1]; however their `long double` differs from the GNU one, and their `wsprintf()` treats %s/%c as wide strings/characters. For standard conformance it's recommended that `__USE_MINGW_ANSI_STDIO` always be defined.
[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l?view=msvc-170#remarks
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
