zig
zig copied to clipboard
translate-c has issues with int signedness in "windows.h"
Zig Version
0.9.1
Steps to Reproduce
Import "windows.h" and try to use LOWORD and HIWORD macros.
Expected Behavior
Works.
Actual Behavior
error: expected type 'c_ulonglong', found 'c_int'
The translated code looks like this:
@import("std").zig.c_translation.cast(WORD, (@import("std").zig.c_translation.cast(DWORD_PTR, l) >> @as(c_int, 16)) & @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffff, .hexadecimal))
Removing the promoteIntLiteral
at the end fixes the issue. 0xffff
can be casted to c_ulonglong
automaticaly, but produces an error when it is promoted to c_int
before that.
Does the suggested fix in the comment here: https://github.com/ziglang/zig/issues/10793#issuecomment-1030504654= fix the issue?
Does the suggested fix in the comment here: #10793 (comment) fix the issue?
No, still the same.
I don't think that the issue is in the function promoteIntLiteral
itself, rather than in the fact that we are using it to convert 0xffff
to signed int.