Using build.zig integration for the {fmt} library - a modern formatting library providing a fast and safe alternative to C stdio and C++ iostreams.
Key features of {fmt}:
- Fast and efficient formatting with type-safe format strings
- Implements C++20 std::format
- Supports user-defined types
- Extensive formatting options and positional arguments
- Modern clean API design
- Header-only and compiled versions available
- zig v0.14.0 or master
Make directory and init
$ zig init
## add in 'build.zig.zon' fmt-zig package
$ zig fetch --save=fmt git+https://github.com/allyourcodebase/fmt-zigAdd in build.zig
const std = @import("std"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const fmt_dep = b.dependency("fmt", .{ .target = target, .optimize = optimize, }); const fmt_artifact = fmt_dep.artifact("fmt"); for(fmt_artifact.root_module.include_dirs.items) |include_dir| { try exe.root_module.include_dirs.append(b.allocator, include_dir); } exe.linkLibrary(fmt_artifact); }