Turbo beginner: How to pass struct

Very basic question I assume. I’m trying out building the zig example from StereoKit. I believe Build.zig is out of date and I need to chage the release options to another function. from this:
const mode = b.standardReleaseOptions();
to this
const mode = b.standardOptimizeOption(?));
And I’m too much of a novice to know how to pass the option for ReleaseSafe in as an argument. Can anyone share some knowledge?

1 Like

If you run the command “zig init-exe”, zig will create a minimal program, incluind a build.zig, that should always compile and be up to date.
You also have the official std documentation.
Documentation - Zig

In the link, you will se that standardOptimizeOption has a parameter of type StandardOptimizeOptionOptions. This type only has one field, meaning you can only specifiy one option. The field is called preferred_optimize_mode, and it has a default initial value, indicated by the fact it has an equal sign:

preferred_optimize_mode: ?std.builtin.OptimizeMode = null,

When a field has a default value, you don’t have to specify the field when instantiating that type. If you are satifisfied with all the default values, you can instantiate a type with all default values by using .{}
So you should write:

const mode = b.standardOptimizeOption(.{});
2 Likes