this is driving me crazy

This is a discussion on this is driving me crazy within the C Programming forums, part of the General Programming Boards category; Can anyone tell why I am getting c=1 b=0 as the output.
I am using the MinGW that comes the ...

> I meant MinGW that comes with the lastest version of bloodshed.
If you do
gcc --version
what do you get?

unsigned long long c=1,b=23;
printf( "%d %d\n", sizeof(c), sizeof(b) );
What do you get?

> unsigned long long c=1,b=23;
> printf("c=%llu b=%llu\n",c,b);
If you compile with
gcc -S prog.c
what do you get in prog.s ?

Compare with calling a function which expects two unsigned long long parameters
void foo ( unsigned long long p1, unsigned long long p2 );
foo( c, b );

Does this fix anything (since printf is a variadic function, and arguments have default promotions)
unsigned long long c=1,b=23;
printf("c=%llu b=%llu\n",(unsigned long long)c, (unsigned long long)b );

gcc.exe (GCC) 3.2 (mingw special 20020817-1)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Does this fix anything (since printf is a variadic function, and arguments have default promotions)
unsigned long long c=1,b=23;
printf("c=%llu b=%llu\n",(unsigned long long)c, (unsigned long long)b );

I did cast the results to unsigned long long in an attempt to make it work, it didn't help.

In short, MSVCRT, which MinGW uses, does not understand "%llu" and interprets it as "%lu". Therefore, you are printing the two halves of the first long long you pass to printf(). You can use "%I64d" and "%I64u" to print signed and unsigned long longs respectively.

In short, MSVCRT, which MinGW uses, does not understand "%llu" and interprets it as "%lu". Therefore, you are printing the two halves of the first long long you pass to printf(). You can use "%I64d" and "%I64u" to print signed and unsigned long longs respectively.