jacob navia a écrit :
> Microsoft has proposed using
>
> %I64d to print a long long.
That is not quite the way I see it.
Some time ago (around 1993), Microsoft introduced in its compiler a new
integer types named __int64, and support for it (only in the 32-bit
compiler IIRC.) The compiler knew how to parse a 64-bit constant when it
was followed by I64, too. The plan then also contemplated using __int128
(try it, you'll see it is still parsed in nowadays compilers), but AFAIR
there were no implementation for it then -- nor now.
In a first try, there were no support for those new types using
*printf() [it was the time when the use of the "CRT" was not always seen
as the way to go by Microsoft.]
Some years later (sorry, I do not have all the Microsoft compilers at
hand, and the web is not precise enough to crop informations about
16-year old compilers, I assume many people consider it somewhat
obsolete or useless), the CRT was enhanced to allow using %I64d to
format the objects. It was certainly before 1996 though. Around the same
time frame, support was also added for __int8, __int16 and _int32.
_Then_ (NOT before), in 1997-99, the C committee introduced in the C99
standard the long long integer type; note the 1998 C++ standard, which
was aligned to the C90 standard, did not have the long long type then.
Since at the same moment there have been a noticeable delay between
Visual C++ 6.0 (1998, without any support for long long) and the next
version (stabilized around 2003), people which had need to manage and
format 64-bit values learned that with the Microsoft (and Borland)
compilers you had to use the __int64 and %I64, while C99-enhanced tools
preferred using long long and %ll --which was much more successful than
the alternate int64_t and %"PRIi64" solution, also available with C99.
Of course, the reactive people at GCC quickly provided a bridging
solution to continue compiling Windows-targeting programs, in the form
of support of the __int64 data type; yet most programmers learned
(incorrectly) that "long long means 64 bits."
Furthermore, and here this is Microsoft's mistake, while the 2002-2003
"Visual C++ for .NET" (VC++ 7.x or v.12 of the compler) had support for
the long long integer type, the accompanying runtime library (MSVCRT7*)
did not have support for the %ll prefix for *printf formatting; this
'defect' is corrected with the next version, "Visual C++ 2005."
Meanwhile, other products like Mingw or lcc-win relied on a mix: they
provided a compiler which is kept up to date, but for the runtime they
rested on the DLL provided with the operating system by Microsoft; this
makes the deployment tasks much easier, but it also locks the program to
use only the features available with the installed runtime; and for a
long time, until 2005, we saw above that this runtime was based on the
C90 set of features, and did not have support for %lld; this is also
true for the Microsoft-compiled programs linked against the always
available msvcrt.dll (a working solution for the major headaches
produced by the "DLL hell" in the years 1994-1996 by slightly
incompatible versions of distributed runtimes erasing themselves in the
system directory of Windows.)
This boils down that, while the compilers happily support long long (and
this idiom is much used by programmers), printf on Windows happens to be
more picky here, and many programmers learned (again incorrectly) to use
%I64 in order to format a long long value. Particularly sneaky since it
works on all the Windows platforms you can reasonably test on.
However, to come back to your sentence, it is NOT "Microsoft proposal."
Quite the reverse: the regular documentation from Microsoft says that to
format __int32 and __int64 values you have to use %I32 and %I64 prefixes
(and also often remark it as Microsoft extensions); and that (since
2005) to format a long long value you have to use %ll prefix.
What has been proposed IIRC (and defeated IISRC) was to standardise the
use of %I64d --and the rest of the crowd-- to be part of the standard,
with the meaning of PRId64; this would be the same as having "jd" being
effectively the same as PRIdMAX. An objection that might raised is about
some lack of existing practice: Microsoft runtime support is limited to
I32 and I64, it is lacking I8 and I16 prefixes, while the integer types
__int8 and __int16 are supported by the compilers.
Antoine