And I have a function like that
extern "c" pub fn foo(grid: dim3)
this func is impl by a C lib.
When I pass the grid to dim3 ,
the C func foo get the grid like that: ( I disassemble the func code) foo( grid_xy: u64,grid:u32)
but the rust pass the grid like that foo( grid_x: u32,grid_y:u32,grid:u32)
when we pass all param by using memory call stack ,there is nothing wrong happened.It's OK.
But X64 pass the param by reg (RSI,RDI etc), so it's a problem~
The signature must match on both sides of FFI. You can't have one side use a signature with a different number of function arguments than the other. It doesn't matter if it sometimes looks like it works; to mismatch signature like that is simply forbidden.
It smells like a calling convention mismatch. If you're relying on disassembly of the dylib instead of a header, knowing for sure is difficult. If this is Windows, it's worth noting DLLs often choose to export functions with extern "system" instead of extern "C" for assorted reasons.