On Wed, Jul 08, 2026 at 03:19:38PM +0200, Florian Weimer wrote:
> * Jakub Jelinek via Gcc:
>
> > As I wrote earlier, I'd like to see _BitInt I/O support in
> > *printf*/*scanf* and extending support of _BitInt in stdbit.h
> > in C2Y.
> >
> > For those I wrote drafts of possible C2Y papers:
> > https://jakubjelinek.github.io/wg14/va_arg_bitint.html
> > https://jakubjelinek.github.io/wg14/stdbit_bitint.html
> >
> > I'd appreciate any comments on this.
>
> Is this going in the right direction, though?
>
> Why shouldn't programmers be able to write %d in the format string and
> print _BitInt arguments this way?
>
> I think it's time to pass a type descriptor for varags functions. Then
> it wouldn't be necessary to pass the _BitInt size as argument to
> va_arg_bitint.
For *printf*/*scanf* I don't see other way, or anything using normal
stdarg.h APIs.
Sure, one can come up with either some extension or new C standard feature,
whether it is an attribute on the ... function or something else, that
would change its ABI such that one passes not just the arguments
corresponding to ... but also their types encoded in some way.
IMHO you still need something like some of the proposed macros to decode
the passed bit-precise integers, you don't want to have millions of separate
cases handling them depending on the known bit-precise integer width.
But then it wouldn't be printf etc. but some new function name, where you
don't need to specify %lld etc. but the format string can look closer to
say std::format.
Jakub