Hey, I was creating something similar to raygui custom file dialog for my project but the GuiListViewEx function gives me the following type error: expected type '[*c][*c]const u8', found '[*c]const [*:0]const u8'. Changing the type fixed it, however I'm new in Zig and maybe I did something wrong.
zig version: 0.12.0-dev.1849+bb0f7d55e
raygui.zig commit: 78c8855
Example:
// dir_files.paths -> [*][*:0]u8
// const paths: [*]const [*:0]const u8 = @ptrCast(state.dir_files.paths);
// This fails too:
const string_arr = [_][*:0]const u8{ "String1", "String2", "String3" };
const paths = &string_arr;
_ = raygui.GuiListViewEx(.{
.x = state.window_bounds.x + 8,
.y = state.window_bounds.y + 48 + 20,
.width = state.window_bounds.width - 16,
.height = state.window_bounds.height - 60 - 16 - 68,
},
paths,
@bitCast(state.dir_files.count),
&state.files_list_scroll_index,
&state.files_list_active,
&state.item_focused
);
Compiler Error:
libs/raygui/raygui.zig:604:9: error: expected type '[*c][*c]const u8', found '[*c]const [*:0]const u8'
libs/raygui/raygui.zig:604:9: note: cast discards const qualifier
Original Function:
pub fn GuiListViewEx(
bounds: Rectangle,
text: [*]const [*:0]const u8,
count: i32,
scrollIndex: *i32,
active: *i32,
focus: *i32,
) i32 {
return raygui.mGuiListViewEx(
@as([*c]raygui.Rectangle, @ptrFromInt(@intFromPtr(&bounds))),
@as([*c]const [*:0]const u8, @ptrFromInt(@intFromPtr(text))),
count,
@as([*c]i32, @ptrCast(scrollIndex)),
@as([*c]i32, @ptrCast(active)),
@as([*c]i32, @ptrCast(focus)),
);
}
Possible Solution:
pub fn GuiListViewEx(
bounds: Rectangle,
text: [*]const [*:0]const u8,
count: i32,
scrollIndex: *i32,
active: *i32,
focus: *i32,
) i32 {
return raygui.mGuiListViewEx(
@as([*c]raygui.Rectangle, @ptrFromInt(@intFromPtr(&bounds))),
--> @as([*c][*c]const u8, @ptrFromInt(@intFromPtr(text))), <--
count,
@as([*c]i32, @ptrCast(scrollIndex)),
@as([*c]i32, @ptrCast(active)),
@as([*c]i32, @ptrCast(focus)),
);
}
Hey, I was creating something similar to raygui custom file dialog for my project but the
GuiListViewExfunction gives me the following type error:expected type '[*c][*c]const u8', found '[*c]const [*:0]const u8'. Changing the type fixed it, however I'm new in Zig and maybe I did something wrong.zig version: 0.12.0-dev.1849+bb0f7d55e
raygui.zig commit: 78c8855
Example:
Compiler Error:
Original Function:
Possible Solution: