From 1899aea29f130b1200b280828a82cdc7693582de Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Fri, 20 Mar 2026 14:28:25 +0100 Subject: [PATCH] Add FMT_FORMAT_ARGS(fmt, ...) macro to C API to simplify user-defined format wrappers --- include/fmt/fmt-c.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/fmt/fmt-c.h b/include/fmt/fmt-c.h index 20d163a7..c82e5d44 100644 --- a/include/fmt/fmt-c.h +++ b/include/fmt/fmt-c.h @@ -181,11 +181,14 @@ typedef enum {} fmt_signed_char; (fmt_arg[]) { FMT_MAP(FMT_MAKE_ARG, ##__VA_ARGS__) } # define FMT_EXPAND(v) v -# define fmt_format(buffer, size, fmt, ...) \ - fmt_vformat((buffer), (size), (fmt), \ - FMT_EXPAND(FMT_VA_SELECT(FMT_MAKE_NULL, FMT_MAKE_ARGLIST, \ - ##__VA_ARGS__)(__VA_ARGS__)), \ - FMT_NARG(, ##__VA_ARGS__)) +# define FMT_FORMAT_ARGS(fmt, ...) \ + (fmt), \ + FMT_EXPAND(FMT_VA_SELECT(FMT_MAKE_NULL, FMT_MAKE_ARGLIST, \ + ##__VA_ARGS__)(__VA_ARGS__)), \ + FMT_NARG(, ##__VA_ARGS__) + +# define fmt_format(buffer, size, fmt, ...) \ + fmt_vformat((buffer), (size), FMT_FORMAT_ARGS((fmt), ##__VA_ARGS__)) #endif // __cplusplus