So, i got the following function:
fn getRequiredExtensions(allocator: std.mem.Allocator) [][*]const u8 {
var glfwExtensionCount: u32 = 0;
var glfwExtensions: [*]const [*]const u8 = @ptrCast(c.glfwGetRequiredInstanceExtensions(&glfwExtensionCount));
var extensions = std.ArrayList([*]const u8).init(allocator);
errdefer extensions.deinit();
// TODO: Handle this error better.
// Error is OutOfMemory, so almost unreachable
extensions.appendSlice(glfwExtensions[0..glfwExtensionCount]) catch unreachable;
if (g_enableValidationLayers) {
// TODO: Same as above
extensions.append(c.VK_EXT_DEBUG_REPORT_EXTENSION_NAME) catch unreachable;
}
logger.debug("Vulkan required extensions: {d}", .{glfwExtensionCount});
// FIX THIS LOOP
for (extensions.items) |value| {
logger.debug(" {s}", .{value});
}
return extensions.toOwnedSlice() catch unreachable;
}
In the last loop, when trying to print the required extensions I get the following compile error:
error: invalid type given to std.mem.span: [*]const u8
I think i kind of know what it means but not sure. Most of the code it’s from a vulkan example I found, so it is possible the problem is in how I get the extensions and not how to print them.
Also, any improvement to the code would be appriciated.