Web lists-archives.com

Re: [Mingw-users] bizarre problem, need help from a mingw developer

Hash: SHA1

On 09/03/16 21:53, mathog wrote:
>> The bottom line is that MSDN says that "%lf" refers to a long
>> double, and __mingw_printf() interprets that to mean a GCC long
>> double.
> According to the C and C++ language standards that is wrong and has
> been for 15 years or so.  Don't modern Microsoft development
> environments now use "%lf" in compliance with the C/C++ language
> standards?

AFAIK, no they do not.  You can read it just as easily as I can, but
MSDN still says that "%lf" refers to a long double, just as "%Lf"
does; however, for users MSVC users, that's mostly irrelevant, because
their compiler doesn't implement long doubles in any way which is
distinct from plain old double.

> The compilers supply their own run time libraries which take 
> precedence for functions like printf() over the very old MSVCRT 
> supplied with the OS,

Yes, newer versions of MSVC use their own individual versions of
MSVCR?.DLL; all are non-free, incompatible with the GPL, and therefore
cannot be used by MinGW, which must use the the MSVCRT.DLL supplied
with the OS.  However, you are quite wrong to describe this as "very
old"; each new version of the OS delivers a new, updated version of
MSVCRT.DLL, (which nonetheless, may not be entirely compatible with
the non-free MSVCR?.DLL variants accompanying MSVC compilers).  What
these compilers may, or may not do, is mostly irrelevant here anyway;
this list exists to serve users of MinGW's GCC, not users of MSVC.

> so doing it the ANSI way is not difficult.  I wonder if they may
> not now also use an 80 bit long double, so that "%Lf" means
> something different from "%f", and long doubles may actually be
> used to print numbers with more precision.

According to MSDN, no.

> I understand you do not much care for the language standard's 
> requirements for "%lf", but since the standard is as it is,

I consider it to be extremely bad programming to rely of a feature
which is expected to have no effect.  What is the point?  Your code
will be significantly more comprehensible -- you write "%f", and
everybody knows what you mean; writing "%lf" introduces an element of
confusion, and, especially when Microsoft enters the equation, makes
your code less robust.

> it would be nice if
> gcc -std=c99
> in mingw linked in a _printf() that did what the language says it
> should do, rather than what MS compilers did long ago (or still do,
> for all I know).  More power to you if you also want to implement
> gcc -std=MSDN
> or something like that, to match the (old?) MS requirements.

Microsoft's compilers have never been ISO-C99 compliant.  In the last
year or so, they have been paying a bit of lip service to C99, but
they still aren't compliant, (and their own conventions continue to
trump ISO standards).  As a Windows compiler implementer, using
Microsoft's runtime, our language reference is MSDN, and MSDN still
says that "%lf" refers to a long double, so the current
__mingw_printf() is somewhat justified in interpreting it so.
Nonetheless, (and I'm getting extremely irritated by being continually
invited to repeat myself here), the next release [*] of mingwrt will
deprecate interpretation of "%lf" in this way, leaning towards a more
ISO-C99 interpretation, (also justifiable on the grounds of
Microsoft's lack of a true long double implementation in any case); it
will, however, continue to support non-standard conventions such as
"%I64d" as an alias for "%lld", (which Microsoft used not to support,
and may still not, in MSVCRT.DLL), and it will add support [*] for the
POSIX.1-2008 "%n$"/"*m$" argument referencing format specifiers.

[*] These changes are already committed to our git code repository, so
if you can't wait for a release, feel free to clone and build it for
yourself.  (The active branch is called "legacy"; don't use "master",
unless you really want the broken v4 implementation).

- -- 

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
Version: GnuPG v2.0.20 (GNU/Linux)


Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe