pub const Init = struct minimal: MinimalInit is a superset of Minimal; the latter is included here.
arena: *std.heap.ArenaAllocatorPermanent storage for the entire process, cleaned automatically on exit. Threadsafe.
gpa: AllocatorA default-selected general purpose allocator for temporary heap allocations. Debug mode will set up leak checking if possible. Threadsafe.
io: IoAn appropriate default Io implementation based on the target configuration. Debug mode will set up leak checking if possible.
environ_map: *Environ.MapEnvironment variables, initialized with gpa. Not threadsafe.
preopens: PreopensNamed files that have been provided by the parent process. This is mainly useful on WASI, but can be used on other systems to mimic the behavior with respect to stdio.
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58pub const Init = struct {
/// `Init` is a superset of `Minimal`; the latter is included here.
minimal: Minimal,
/// Permanent storage for the entire process, cleaned automatically on
/// exit. Threadsafe.
arena: *std.heap.ArenaAllocator,
/// A default-selected general purpose allocator for temporary heap
/// allocations. Debug mode will set up leak checking if possible.
/// Threadsafe.
gpa: Allocator,
/// An appropriate default Io implementation based on the target
/// configuration. Debug mode will set up leak checking if possible.
io: Io,
/// Environment variables, initialized with `gpa`. Not threadsafe.
environ_map: *Environ.Map,
/// Named files that have been provided by the parent process. This is
/// mainly useful on WASI, but can be used on other systems to mimic the
/// behavior with respect to stdio.
preopens: Preopens,
/// Alternative to `Init` as the first parameter of the main function.
pub const Minimal = struct {
/// Environment variables.
environ: Environ,
/// Command line arguments.
args: Args,
};
}
A standard set of pre-initialized useful APIs for programs to take advantage of. This is the type of the first parameter of the main function. Applications wanting more flexibility can accept
Init.Minimalinstead.Completion of https://github.com/ziglang/zig/issues/24510 will also allow the second parameter of the main function to be a custom struct that contain auto-parsed CLI arguments.