[RFC v1] libio/: Add [v]aprintf()

Joseph Myers josmyers@redhat.com
Tue Mar 17 20:40:09 GMT 2026


On Tue, 17 Mar 2026, Alejandro Colomar wrote:

> diff --git a/libio/stdio.h b/libio/stdio.h
> index 3bf6a1f6..3db363f1 100644
> --- a/libio/stdio.h
> +++ b/libio/stdio.h
> @@ -410,6 +410,14 @@ extern int __asprintf (char **__restrict __ptr,
>  extern int asprintf (char **__restrict __ptr,
>  		     const char *__restrict __fmt, ...)
>       __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
> +
> +/* Write formatted output to a string dynamically allocated with `malloc'.  */
> +extern char *vaprintf (const char *__restrict __f, __gnuc_va_list __arg)
> +     __THROWNL __attribute__ ((__format__ (__printf__, 1, 0)))
> +     __attribute_malloc__;
> +extern char *aprintf (const char *__restrict __fmt, ...)
> +     __THROWNL __attribute__ ((__format__ (__printf__, 1, 2)))
> +     __attribute_malloc__;
>  #endif

Extensions should be conditioned on __USE_GNU, or __USE_MISC given a good 
enough argument to enable them by default.  They don't belong in a defined 
(__USE_MISC) || __GLIBC_USE (LIB_EXT2) section because they aren't in TR 
24731-2, which is what __GLIBC_USE (LIB_EXT2) is for.

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-alpha mailing list