Menu

#520 whether __USE_MINGW_ANSI_STDIO still actual

v1.0 (example)
closed-invalid
nobody
None
5
2015-12-16
2015-12-15
sav
No

Perhaps question has been raised before, but I would venture.

As mentioned on https://sourceforge.net/p/msys2/wiki/Porting/ :
"The vc6.0 msvcrt.dll that MinGW-w64 targets doesn't implement support for the ANSI standard format specifiers. MinGW-w64 works around this by providing their own implementation. To enable this you should pass -D__USE_MINGW_ANSI_STDIO=1 to the MinGW-w64 C and C++ compilers."

On the other side, the L modifier has been standard for a long time (it was added in ISO C89).

The expected output for printf test

#include <stdio.h>

int main (void) {
    long double d = 1. / 31.;
    printf ("%Lf\n", d);
    return 0;
}

is 0.032258. Tested with:

  • recent versions (and not so) of Microsoft/Intel compilers for x86 and 64 platforms print '0.032258',
  • recent versions of MinGW-W64 (i686-posix-sjlj-rev0) print -0.000000,
  • recent versions of MinGW-W64 (x86_64-posix-seh-rev0) print 0.000000,
  • recent versions of MinGW-W64 for x86 and 64 platforms with "-D__USE_MINGW_ANSI_STDIO" parameter print '0.032258',

My question, what keeps MinGW-W64 developers from targeting MinGW-W64 to more recent MSVC runtime 'msvcrt.dll' and move "-D__USE_MINGW_ANSI_STDIO" to trash? After all very unlikely, that someone needs backward MinGW-W64 compatibility with non-working 'L' length modifier for formatted output (e.g. printf with %Lf) and inconsistency to ISO C89.

Thanks!

Discussion

  • Jonathan Yong

    Jonathan Yong - 2015-12-16
    • status: open --> closed-invalid
     
  • Jonathan Yong

    Jonathan Yong - 2015-12-16

    Controlling which version version of MSVCRT.DLL the user has is out of the scope of this project.

     
  • sav

    sav - 2015-12-16

    Well, I rephrase my question: what keeps MinGW-W64 developers from making MinGW-W64 with full compliance to ISO C89 by default and move "-D__USE_MINGW_ANSI_STDIO" to trash?

    UPD: You have closed the topic even before posted a reply. Whether you do not have to clarify the issue even if question contains inaccuracies?

     

    Last edit: sav 2015-12-16
  • Jonathan Yong

    Jonathan Yong - 2015-12-16

    This is not a bug, not in the slightest, it is meant to work this way. The macro means using mingw-w64's own copy of printf routines instead, nothing to do with C99 compatibility, though that is one of the main side effects.

    As you may not know, the reason %LF works in MSVC but not on mingw-w64 even on modern systems is because long double in MSVC is an alias to double, while gcc is using the longer 80-bit variant, with mingw_printf being able to handle it via %LF.

    So no, assuming MSVCRT is C99 compliant does not magically fix everything, not until you can petition Microsoft to break ABI compatibility with all their existing releases.

     
  • sav

    sav - 2015-12-16

    Thanks for a comprehensive answer!

     

Log in to post a comment.

MongoDB Logo MongoDB