compat.fmt
#includeA modern formatting library for C++ — header form (#include <fmt/format.h>)
#include <fmt/fmt-c.h>
mcpp add compat.fmt@12.2.0
Usage
From this repository's own test project — built and run by CI, not written for the website.
// compat.fmt's `c-api` feature: the two entry points of src/fmt-c.cc, called
// through fmt/fmt-c.h's `extern "C"` surface. Both are declared in the header,
// and only this TU (or a consumer's) can provide them — with the feature off
// this file does not link. See this member's mcpp.toml for why the calls are
// spelled this way instead of through the header's C-only fmt_format macro.
//
// Nothing here needs a file on disk: the format side is asserted in memory,
// and fmt_vprint runs against a stream the process owns (tmpfile is unlinked
// on close), so a passing test prints nothing.
#include <fmt/fmt-c.h>
#include <cstdio>
#include <string>
int main() {
fmt_arg args[2] = {};
args[0].type = fmt_cstring;
args[0].value.cstring = "world";
args[1].type = fmt_int;
args[1].value.int_value = 42;
const std::string expected = "hello world #42";
// …
tests/examples/fmt-c/tests/c_api.cpp · project tests/examples/fmt-c
Build
- targets
fmt (lib)- language
c++23- C standard
c11- import std
- no
- include dirs
*/include
Features
| feature | declares |
|---|---|
| c-api | sources |
Sources (2)
*/src/format.cc*/src/os.cc
Versions
| Version | Platforms | Mirrors | sha256 |
|---|---|---|---|
12.2.0 latest |
LinuxWindowsmacOS | source | 8b852bb5aa6e… |