ziglang/zig

Missing optional for lpName param on std.os.windows.kernel32.CreateEventExW

Pyrolistical opened this issue · 1 comments

Zig Version

0.13.0-dev.75+5c9eb4081

Steps to Reproduce and Observed Behavior

According to https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createeventexw, CreateEventExW has the signature:

HANDLE CreateEventExW(
  [in, optional] LPSECURITY_ATTRIBUTES lpEventAttributes,
  [in, optional] LPCWSTR               lpName,
  [in]           DWORD                 dwFlags,
  [in]           DWORD                 dwDesiredAccess
);

but in std, it is defined as:

pub extern "kernel32" fn CreateEventExW(
lpEventAttributes: ?*SECURITY_ATTRIBUTES,
lpName: [*:0]const u16,
dwFlags: DWORD,
dwDesiredAccess: DWORD,
) callconv(WINAPI) ?HANDLE;

Note lpName type does not match. It should be lpName: ?LPCWSTR

Expected Behavior

std.os.windows.kernel32.CreateEventExW signature should match the win32 api

Another issue is there is no way to force a pointer to zero address as the zig compiler does a really good job at detecting that. It would have been nice to be able to @allowzeroCast(@as([*:0]allowzero const u16, @ptrFromInt(0)) or something to bypass compiler.