Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Feb 2025 17:24:45 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>
Cc:        hackers@freebsd.org
Subject:   Re: %b with uint64_t?
Message-ID:  <86frkvgfn6.fsf@ltc.des.dev>
In-Reply-To: <157p941p-159p-rn75-2qo9-6762o7sprq40@yvfgf.mnoonqbm.arg> (Bjoern A. Zeeb's message of "Sat, 1 Feb 2025 01:07:37 %2B0000 (UTC)")
References:  <157p941p-159p-rn75-2qo9-6762o7sprq40@yvfgf.mnoonqbm.arg>

index | next in thread | previous in thread | raw e-mail

"Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net> writes:
> I recently ran into a problem with a uint64_t bitflag to use the %b
> print format in the kernel.

The correct format string to print a uint64_t as binary is %w64b.  You
may have to disable -Wformat locally to get it to compile cleanly:

    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wformat"
            printf("%w64b\n", num);
    #pragma GCC diagnostic pop

DES
-- 
Dag-Erling Smørgrav - des@FreeBSD.org


home | help

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