On Sun, Oct 25, 2009 at 5:55 PM, David Cleaver <wrai...@morpheus.net> wrote: > Hello, > > I'm having problems printing out values that are larger than 32 bits. My > usual > printf using %llu only outputs the lower 32 bits of my 64-bit numbers. > > Here's an example program that produces incorrect output. > > #include <stdio.h> > > typedef unsigned long long u64_t; > > int main(int argc, char* argv[]) > { > u64_t y=6981463658333LL; > printf("y=%llu\n", y);
%llu is not supported by printf in msvcrt.dll. You can use %I64u which is the one supported by ms. Or you can use __mingw_printf(), instead, either explicitly, or indirectly by defining __USE_MINGW_ANSI_STDIO as 1, for example by adding -D__USE_MINGW_ANSI_STDIO=1 to your CFLAGS, which will automaticly replace all printf family of functions with their __mingw_ counterparts. > printf("y=%PRIu64\n", y); Wrong syntax. First you must #include <inttypes.h> for this. Then, the correct form should be like printf("y=%" PRIu64 "\n", y); > printf("y=%qd\n", y); Same as %ll stuff. > printf("y=%x\n", y); > return 0; > } > > Here is the output I get. > y=2141802333 > y=PRIu64 > y=qd > y=7fa94f5d > > Can anyone see what I'm doing wrong? What is the proper way to output 64-bit > numbers? I'm using mingw-w64-bin_i686-mingw_20091025.zip for my development > environment and I've called the compiler like: > x86_64-w64-mingw32-gcc.exe -o test.exe test.c > > Thanks for any help. > > -David C. Use -Wall (or -Wformat) to get warnings about what is supported and what is not. Hope these help. -- Ozkan ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public