Re: cross platform

From: David O'Brien <obrien_at_freebsd.org>
Date: Sat, 12 Feb 2005 22:24:19 -0800
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)
Received on Sun Feb 13 2005 - 05:24:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:28 UTC