Subject: Re: printf(3) bug with %ld and %d?
To: None <tech-userlevel@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-userlevel
Date: 10/30/2006 08:37:20
On Mon, 30 Oct 2006, Christos Zoulas wrote:
> off_t is a 64 bit quantity, long long on i386. So you should really
> 
> printf("Long before (%lld), integer after (%d)\n", (long long)offset, n);
> 
> Unfortunately there is no printf format char like there is for size_t, and
> ptrdiff_t.

You could cast to intmax_t and print with "%jd".  Unlike long long,
intmax_t is guaranteed by the C language to be the widest available
integer type.  (There may be implementation-defined extended integral
types wider than long long, but no existing NetBSD ports have any of
those.)

--apb (Alan Barrett)