You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In examples/main.zig:52, I got a C struct that represents the current mouse position.
The position's y value should be changed into the correct value, as the mouse moves.
Snippets:
examples/main.zig
constraylib=@cImport({@cInclude("raylib.h");});
//...constmousePosition=raylib.GetMousePosition(); // It returns raylib.Vector2circle.position.x=@floatToInt(i32,mousePosition.x);
circle.position.y=@floatToInt(i32,mousePosition.y);
The value of mousePosition.y is always 0.
This does not happen when the target is native x86_64-linux.
It only happens when the target is x86_64-windows-gnu. I tested this in both Linux (cross-compile) and Windows (native) hosts.
I also tried compiling c code(core_input_mouse.c) that uses GetMousePosition(), then it worked correctly.
I used vsdbg for debugging this, but I cannot find any solution.
All the values from the raylib struct, CORE.Input.Mouse(raylib/src/rcore.c:3745) , were correct.
But when the mouse position struct passed to zig, its y value suddenly became 0.
Is it related to alignment or something?
The text was updated successfully, but these errors were encountered:
km19809
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Jan 10, 2022
I imagine this might be a C ABI *compatibility issue (as in, currently unimplemented / incorrect implementation).
Issue #1481 tracks this for stage1 - the checkmark for "x86_64: struct & union return values <= 16 bytes" is unticked.
You might be able to work around this in the short term by storing the struct somewhere in C code and only passing the pointer over to Zig.
I imagine this might be a C ABI *compatibility issue (as in, currently unimplemented/incorrect implementation). Issue #1481 tracks this for stage1 - the checkmark for "x86_64: struct & union return values <= 16 bytes" is unticked. You might be able to work around this in the short term by storing the struct somewhere in C code and only passing the pointer over to Zig.
I changed the function to the other one that does not return a struct. It worked.
As you said, it was a C ABI problem. It seems duplicated, so I'll close this issue.
Thank you for your comment!
Zig Version
0.9.0
Steps to Reproduce
Expected Behavior
In
examples/main.zig:52
, I got a C struct that represents the current mouse position.The position's
y
value should be changed into the correct value, as the mouse moves.Snippets:
examples/main.zig
raylib/src/rcore.c:3737
raylib.Vector2
in auto-generatedcimport.zig
Actual Behavior
The value of
mousePosition.y
is always 0.This does not happen when the target is native x86_64-linux.
It only happens when the target is x86_64-windows-gnu. I tested this in both Linux (cross-compile) and Windows (native) hosts.
I also tried compiling c code(
core_input_mouse.c
) that usesGetMousePosition()
, then it worked correctly.I used vsdbg for debugging this, but I cannot find any solution.
All the values from the raylib struct,
CORE.Input.Mouse
(raylib/src/rcore.c:3745
) , were correct.But when the mouse position struct passed to zig, its
y
value suddenly became 0.Is it related to alignment or something?
The text was updated successfully, but these errors were encountered: