Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

addCSourceFiles

Handy when you have many non-Zig source files and want them all to have the same flags.

Module.addCSourceFiles
pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void

File

lib/std/Build/Module.zig:388

Code

pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
    const b = m.owner;
    const graph = m.owner.graph;
    const arena = graph.arena;

    for (options.files) |path| {
        if (std.fs.path.isAbsolute(path)) {
            std.debug.panic(
                "file paths added with 'addCSourceFiles' must be relative, found absolute path '{s}'",
                .{path},
            );
        }
    }

    const c_source_files = arena.create(CSourceFiles) catch @panic("OOM");
    c_source_files.* = .{
        .root = options.root orelse b.path(""),
        .files = b.dupeStrings(options.files),
        .flags = b.dupeStrings(options.flags),
        .language = options.language,
    };
    m.link_objects.append(arena, .{ .c_source_files = c_source_files }) catch @panic("OOM");
}