Hello! I have been getting this compilation: error: "/home/deck/Projects/try-zig/src/impl_x11.zig:120:21: error: expected type 'i32', found 'c_ulong'
14, 19, 15 => continue,
^~
/home/deck/Projects/try-zig/src/impl_x11.zig:120:21: note: signed 32-bit int cannot represent all possible unsigned 64-bit values". At first, this error stated that the source of the problem was when I did "if(xevent.xkey.type == xlib.KeyPress) but when I try to cast with @truncate, @intCast, or @as, or when I commented it out it still states it is a problem or the source of the error is somewhere else that doesn;t make sense. I assume the compiler is mistaken and perhaps the syntax is off somehow? Here is the source file of the code if it helps. Also sorry if the formatting of this post is not appropitately formatted. Thanks!
#Weird int type error
1 messages · Page 1 of 1 (latest)
does it still issue that error if you remove the 14, 19, 15 case?
Yes, but in a different location that doesn't make sense. "/home/deck/Projects/try-zig/src/impl_x11.zig:103:17: error: expected type 'i32', found 'c_ulong'
KP, KR => {
^~
/home/deck/Projects/try-zig/src/impl_x11.zig:103:17: note: signed 32-bit int cannot represent all possi
ble unsigned 64-bit values"
my best guess is its coming from .keycode = @as(i32, translate_xkey(&xevent.xkey))
I defined KR and KP as i32 constants which are compared with xevent.type which is also an i32.
KR and KP aren't i32s in the source, they're just comptime_ints, which will either coerce, or compile error if they can't
so not relevant
what is the type of prev_key_event, and what is the type of xevent.key
might be related to prev_key_event = xevent.key;, just bad source location
either that, or what @knotty lance said
@as can't cast
it only coerces
in order to cast integers, you have to use @intCast
Ahh I got it now. I needed to change xevent.key to xevent.xkey and also I changed line 15 to @intCast(i32, xlib.XLookupKeysym(xkey, 0)).
did that fix it?