Date: Thu, 30 Oct 2014 20:53:49 -0400 From: Eric van Gyzen <eric@vangyzen.net> To: Rick Macklem <rmacklem@uoguelph.ca>, Freebsd hackers list <freebsd-hackers@freebsd.org> Subject: Re: how to kernel printf a int64_t? Message-ID: <5452DD9D.6060508@vangyzen.net> In-Reply-To: <439339249.2551223.1414702876172.JavaMail.root@uoguelph.ca> References: <439339249.2551223.1414702876172.JavaMail.root@uoguelph.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/30/2014 17:01, Rick Macklem wrote:
> I feel kinda dumb asking this, but...
> int64_t i;
>
> printf("%qd\n", (u_quad_t)i);
>
> works but looks dorky, to put it technically;-).
> Is there a better way to printf() a int64_t in the kernel?
The ANSI C way would be:
#include <machine/_inttypes.h>
int64_t i;
printf("%"PRId64"\n", i);
It's probably bad form to directly #include a file name with an
underscore into an implementation file, but I don't see any other way.
Maybe we could create a <sys/inttypes.h> that #includes the necessary
files to be a kernel equivalent of <inttypes.h>.
Eric
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5452DD9D.6060508>
