mcpp index

compat.fmt

#include

A modern formatting library for C++ — header form (#include <fmt/format.h>)

#include <fmt/fmt-c.h>
mcpp add compat.fmt@12.2.0

用法

來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。

// 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 · 專案 tests/examples/fmt-c

建置

targets
fmt (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/include

功能

功能宣告了
c-apisources

原始檔 (2)

  • */src/format.cc
  • */src/os.cc

版本

版本平台 鏡像sha256
12.2.0 最新 LinuxWindowsmacOS 來源 8b852bb5aa6e…