#251 printf function does not support long long

printf (3)
Matt Ball

The printf function does not correctly handle long
long input parameters in the MinGW environment
(and possible other environments). The printf
function appears to attempt to handle the long
long input. However, it only pulls off one 32-bit
parameter, and does not process the second 32-bit
parameter for the long long. The next format
descriptor will typically use the upper 32-bits of
the previous long long parameter.

Here is code that could repeat this problem:

long long A = 12345678901234LL, B =
printf("%lld, %lld\n", A, B);

GCC release: gcc (GCC) 3.2 (mingw special

Mingw release: MinGW 2.0.0-3 running under
Windows NT


  • Danny Smith

    Danny Smith - 2003-01-02

    Logged In: YES

    MSVC printf does not recognize "ll" identifier, use "I64"
    printf("%I64d, %I64d\n", A, B);


  • Matt Ball

    Matt Ball - 2003-01-02

    Logged In: YES

    Thanks for the info!
    The I64 approach will work for what I'm doing.
    However, there is still a descrepancy between gcc and
    libc. gcc does not appear to recognize the "I64" format
    specifier, and will issue a warning whenever C code
    includes it. The printf function in libc does not
    recognize the "ll" format prefix. However, gcc will not
    issue any warning if the C program uses "ll". In a future
    release we may want to resolve the differences in
    warnings issued by gcc, and what is implement for
    printf in libc. "ll" may be an ANSI C99 standard, so it
    might be worth implementing at some point.

  • Luke Dunstan

    Luke Dunstan - 2003-01-03

    Logged In: YES

    The C library that you are calling "libc" is the msvcrt.dll library
    provided my MS, so it is difficult to do anything to support "ll".
    Changing GCC's format checking would be easier but it is a
    fairly low priority at this stage, and I would guess that such a
    change may not be accepted for mainline GCC.

  • Earnie Boyd

    Earnie Boyd - 2003-01-03

    Logged In: YES

    I have someone working on an alternative library that will
    provide this capability. I have a pre-alpha version of the
    library, if you wish I can forward it to you, with the
    caveat that the name of the library may change in the final
    release. It's license is BSD with advert.


  • Matt Ball

    Matt Ball - 2003-01-03

    Logged In: YES

    Thanks for the offer. However, for my purposes, using
    I64 should work. The confusion happened because I
    didn't realize that MinGW uses msvcrt.dll instead of libc.

  • Matt Ball

    Matt Ball - 2003-01-03
    • status: open --> closed-works-for-me
  • Earnie Boyd

    Earnie Boyd - 2013-01-30
    • labels: gcc --> printf
    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> Known_bugs
    • milestone: --> WSL

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks