cross platform
David O'Brien
obrien at freebsd.org
Sun Feb 13 06:24:22 GMT 2005
On Sun, Feb 13, 2005 at 04:50:46AM +0000, Joseph Koshy wrote:
> > - How do I know which is the right directive? Is this documented
> > somewhere?
> What's the problem exactly?
>
> I had a problem with printing uint64_t values portably between
> the AMD 64 and i386. My debug printfs had to use either
> "%lx" or "%llx". The workaround (hack) was to use CPP
> liberally (#define U64FORMAT "%l" or "%ll").
>
> I wonder if there is a better (more portable) way.
The ISO C standard way is to use "PRIx64". See
/usr/include/machine/_inttypes.h.
The FreeBSD way is to use %jd and cast the value to (maxint_t).
--
-- David (obrien at FreeBSD.org)
More information about the freebsd-current
mailing list