From d694b8031ac765f8b645ab093925752e01db89a5 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 6 Nov 2022 15:02:55 -0700 Subject: [PATCH] glfw: ensure Window.from handle is untyped Since users of the library do not have access to the `@cImport` struct (and we do not want to expose that), the user may pass only an untyped `*anyopaque` pointer which we'll internally cast to `*c.GLFWwindow`. Signed-off-by: Stephen Gutekanst --- libs/glfw/src/Window.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/glfw/src/Window.zig b/libs/glfw/src/Window.zig index bea54ab4..be447d6e 100644 --- a/libs/glfw/src/Window.zig +++ b/libs/glfw/src/Window.zig @@ -23,8 +23,8 @@ const Window = @This(); handle: *c.GLFWwindow, /// Returns a Zig GLFW window from an underlying C GLFW window handle. -pub inline fn from(handle: *c.GLFWwindow) Window { - return Window{ .handle = handle }; +pub inline fn from(handle: *anyopaque) Window { + return Window{ .handle = @ptrCast(*c.GLFWwindow, @alignCast(@alignOf(*c.GLFWwindow), handle)) }; } /// Resets all window hints to their default values.