I'm currently working on code gen for GDExtension. I have this function
pub var variant_from_string: interface.VariantFromTypeConstructorFunc = null;
const std = @import("std");
pub fn init(p_get_proc_address: interface.InterfaceGetProcAddress) !void {
fns.init(p_get_proc_address);
init_type_api(fns);
init_singletons(fns);
init_util_func(fns);
variant_from_string = fns.get_variant_from_type_constructor.?(interface.VariantTypes.STRING);
var string: types.String = undefined;
var variant: types.Variant = .{ .no_touch = std.mem.zeroes([24]u8) };
fns.string_new_with_utf8_chars.?(&string, "ZIG IS FULLY INITILIZED!!!\n");
variant_from_string.?(
&variant,
&string,
);
@setRuntimeSafety(false);
util_fns.general.@"print 2648703342"(variant);
@setRuntimeSafety(true);
}
with the error
gdextension/api.zig:28:41: error: use of undefined value here causes undefined behavior
util_fns.general.@"print 2648703342"(variant);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
referenced by:
initalize: src/extension.zig:14:12
hello_extension_entry: src/extension.zig:31:25
remaining reference traces hidden; use '-freference-trace' to see all reference traces
error: the following command failed with 1 compilation errors:
I don't understand why the compiler believes the variant is undefined.
I was hoping I could just disable the check(setRuntimeSafety), but
- It didn't work
- I should probably fix the underlying issue