There is a well-defined binary interface between top-level functions such as fmt::format and their type-erased counterparts like fmt::vformat. This interface relies only on basic C++ features and should be compatible with C (except for the overload returning std::string obviously). As a result, it may be possible to provide a C API that builds argument lists using _Generic and invokes the type-erased functions.
Unlike the printf family of functions, such an API could be fully type-safe, including for runtime format strings, and would not rely on encoding type information in the format string itself.
This issue is opened to gauge interest. React with a 👍 or another emoji if you would use this.
There is a well-defined binary interface between top-level functions such as
fmt::formatand their type-erased counterparts likefmt::vformat. This interface relies only on basic C++ features and should be compatible with C (except for the overload returningstd::stringobviously). As a result, it may be possible to provide a C API that builds argument lists using_Genericand invokes the type-erased functions.Unlike the
printffamily of functions, such an API could be fully type-safe, including for runtime format strings, and would not rely on encoding type information in the format string itself.This issue is opened to gauge interest. React with a 👍 or another emoji if you would use this.