Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 05 Jun 2011 21:40:39 +0100
From:      Ben Laurie <ben@links.org>
To:        "Sean C. Farley" <scf@FreeBSD.org>
Cc:        hackers@FreeBSD.org
Subject:   Re: int64_t and printf
Message-ID:  <4DEBE9C7.4030505@links.org>
In-Reply-To: <alpine.BSF.2.02.1106051426190.9196@thor.farley.org>
References:  <4DEBC741.1020200@links.org> <alpine.BSF.2.02.1106051426190.9196@thor.farley.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 05/06/2011 19:31, Sean C. Farley wrote:
> On Sun, 5 Jun 2011, Ben Laurie wrote:
> 
>> So, for example int64_t has no printf modifier I am aware of. Likewise
>> its many friends.
>>
>> In the past I've handled this by having a define somewhere along the
>> lines of...
>>
>> #if <something>
>> # define INT_64_T_FMT "%ld"
>> #else
>> # define INT_64_T_FMT "%lld"
>> #endif
>>
>> but I have no idea where to put such a thing in FreeBSD. Opinions?
>> Also, I guess I'd really need to do a modifier rather than a format,
>> for full generality.
> 
> You need to include inttypes.h, which includes machine/_inttypes.h. This
> will provide the appropriate macro which in this case is PRId64.

I somewhat love this plan. Apparently it doesn't work:

/scratch/tmp/benl/work/head/cddl/lib/libdtrace/../../../cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c:963:40:
error: expected ')'
                (void) snprintf(c, sizeof (c), "0x%" PRIx64, addr);
                                                     ^

(ref9-amd64).

-- 
http://www.apache-ssl.org/ben.html           http://www.links.org/

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DEBE9C7.4030505>