dimdin
February 25, 2024, 1:45pm
2
Hello @Skarsh , welcome to the forum.
While LPCWSTR
declaration remains the same, zig type system is not going to let you have a misaligned value.
You can use MAKEINTRESOURCEA with LoadCursorA, and use LoadCursorW when you have a string name.
Please note that there are windows bindings automatically generated from windows metadata
There was a similar issue with HWND_TOPMOST
passed as a pointer with value -1
:
This seems like C compiler semantics and Zig semantics interacting badly, so the unaligned “address” -1 is accepted by a C compiler but not Zig. There might be a good language-level solution to this, like making all [*c] pointers align(1). I don’t think there’s a good workaround for this except to redefine redeclare the SetWindowPos function:
const WINAPI: std.builtin.CallingConvention = if (@import("builtin").cpu.arch == .x86) .Stdcall else .C;
extern fn SetWindowPos(
hWnd: c.HWND
hWnd…
2 Likes