Re: 64 bit printf() format prefix compatibility problem

From: Alan Barrett <apb@dont-contact.us>
Date: Sun, 10 Aug 2003 13:14:17 +0200

On Sun, 10 Aug 2003, Serassio Guido wrote:
> gcc uses "ll" as 64 bit formatting prefix for printf, where MSVC uses "I64".

In C++, as Robert said, using operator<< would be better.

In standard C (C99), the way to handle this is to include <inttypes.h>
to get definitions of PRId64 and friends. Then you do stuff like this:

    int64_t foo;
    printf("foo=%"PRId64"\n", foo);

If your compiler or system library doesn't supply the PRIxxx macros that
are supposed to be in <inttypes.h>, then you could define them somewhere
conditional on the compiler or system.

--apb (Alan Barrett)
Received on Sun Aug 10 2003 - 05:15:22 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:20:27 MST