Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 05 Jun 2011 18:21:24 +0000
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Ben Laurie <ben@links.org>
Cc:        hackers@freebsd.org
Subject:   Re: int64_t and printf 
Message-ID:  <11705.1307298084@critter.freebsd.dk>
In-Reply-To: Your message of "Sun, 05 Jun 2011 19:13:21 %2B0100." <4DEBC741.1020200@links.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <4DEBC741.1020200@links.org>, Ben Laurie writes:

>So, for example int64_t has no printf modifier I am aware of. Likewise
>its many friends.

>but I have no idea where to put such a thing in FreeBSD. Opinions? 

I have totally given up on this mess.

At best you get incredibly messy source code, at worst you waste a
lot of time figuring out why who to define stuff to make some platform
you have only heard rumours about behave.

I have therefore resorted to printf'ing any typedefed integer type using
"%jd" and an explicit cast to (intmax_t):

	printf("%-30s -> %jd -> %s\n", s, (intmax_t)t, buf);

If some system introduces int512_t that may not be optimal, but
since printf is a pretty slow operation anyway, I doubt it will
hurt even half as much as the alternative.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



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