I know this is probably a very simple question, but is there a single consistent way to write main.zig across MacOS and Linux (or just cross platform in general really)? For Linux I found this works:
pub fn main(init: std.process.Init) !void {
// Initialise allocator
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator: std.mem.Allocator = gpa.allocator();
// Read Argv for file path
var args = try init.minimal.args.iterateAllocator(allocator);
_ = args.skip();
const path: [:0]const u8 = args.next() orelse return error.MissingArgs;
// Initialise IO implementation
var threaded: std.Io.Threaded = .init(allocator, .{ .environ = init.minimal.environ });
const io = threaded.io();
defer threaded.deinit();
// etc
}
Whereas when I try to do the same thing on Mac I get “error: root source file struct ‘process’ has no member named ‘Init’” and have to do something like this instead:
pub fn main() !void {
// Initialise allocator
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator: std.mem.Allocator = gpa.allocator();
// Read Argv for file path
var args = std.process.args();
_ = args.skip();
const path: [:0]const u8 = args.next() orelse return error.MissingArgs;
// Initialise IO implementation
var threaded: std.Io.Threaded = .init(allocator, .{});
const io = threaded.io();
defer threaded.deinit();
// etc
}
Any help would be greatly appreciated!