Error: In Windows, use initWithAllocator instead

I am new to Zig language, please bear if the question is too silly. I can’t run the following Mandelbrot file (named 1.zig) on Windows (it works on Ubuntu)

because when trying to run, the error " In Windows, use initWithAllocator instead" pops up, it seems related to the process.zig file called by the get_n function at line 101:29. Any hint?

You have to use argsWithAllocator on Windows. I didn’t test, but changing get_n to the following would likely fix the args issue for Windows.

fn get_n() !usize {
    var arg_it = std.process.argsWithAllocator(global_allocator);
    defer arg_it.deinit();
    _ = arg_it.skip();
    const arg = orelse return 200;
    return try std.fmt.parseInt(usize, arg, 10);

Read the documentation: Documentation - Zig

Replace args with argsWithAllocator in the gen_n function.

The error is a bit unfriendly because args calls ArgIterator.init();

I tried that too. Unfortunately it seemed to not recognize .skip(). Thanks anyway.

What version of Zig are you using?. The skip method should work for Windows.

You have to add try to the call so you get the actual iterator on success:

var arg_it = try std.process.argsWithAllocator(global_allocator);

It works, thank you very much!

You should always report the error messages printed by the compiler.