Originally Posted by
swoopy
>With gcc on my Windows XP box this works:
Thanks for the info Dave. Maybe I've got an old version of gcc. I'll try your exact code tomorrow with Dev-C++ and see what happens.
>(If you run gcc -pedantic, it mentions that ISO C90 does not support the 'll' printf modifier.)
I'll give that a try too, and see if that warning shows.
Well, I don't use dev-cpp for windows console apps and I hadn't tried it. (I use command line cygwin gcc for most things.)
Here's what I found about printing 64-bit ints with dev-cpp:
No need to "update". I doubt that it would change things. Format type specifiers can be found (the "right way") in <inttypes.h> (which includes <stdint.h>)
Here's something that runs on dev-cpp and other gnu gcc on my Windows XP box:
Code:
#include <stdio.h>
#include <inttypes.h>
uint64_t make_longlong(uint32_t, uint32_t);
int main ()
{
uint64_t start, end, diff;
uint32_t hi, lo;
hi = 0x12345678;
lo = 0x9abcdef0;
start = make_longlong(hi, lo);
hi = 0x55555555;
lo = 0x11111111;
end = ((uint64_t)hi << 32) | lo;
diff = end - start;
printf("end = %"PRIu64" (%"PRIx64" hex)\n",end, end);
printf("start = %"PRIu64" (%"PRIx64" hex)\n",start, start);
printf("diff = %"PRIu64" (%"PRIx64" hex)\n",diff, diff);
getchar();
return 0;
}
/* if you want to make a function to hide the bit shifting
* here's a possibility
*/
uint64_t make_longlong(uint32_t hi, uint32_t lo)
{
return ((uint64_t)hi << 32) | lo;
}
output is
Code:
end = 6148914690091192593 (5555555511111111 hex)
start = 1311768467463790320 (123456789abcdef0 hex)
diff = 4837146222627402273 (4320fedc76543221 hex)
Regards,
Dave