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
If the struct's size is lager then 8 bytes, you have to use a pointer as parameter. For return values you have to pass it as first argument. Here is another example from raylib-go:
I'd like to take a crack at this. I have a windows machine (amd64) and a macbook (arm64 with Rosetta), so I can properly test and maintain this.
I'm assuming this involves moving struct_amd64.go/struct_arm64.go to struct_darwin_amd64.go/struct_darwin_arm64.go (with appropriate build tags), then creating a new struct_windows_amd64.go. If that's the case, I'd just need to write addStruct + others that comply with Microsoft's x64 calling conventions?
I'm most definitely missing something, so let me know!
That should pretty much be it. Idk if the amd64 windows ABI needs any special registers like arm64 did so that might complicate. Also I think that arm64 windows should have the same ABI as macOS so those can be shared
Sounds good! I don’t think I’ll be able to test arm64 windows (unless there’s an easy emulator I can utilize). Would you rather me leave it out or include it in the build tags (+ add it to the CICD pipeline)?
Apparently, it's not difficult to fix purego to pass structs, but it's quite difficult to treat structs in callbacks. This requries to implement the callback system by ourselves instead of syscall's NewCallback.
Apparently, it's not difficult to fix purego to pass structs, but it's quite difficult to treat structs in callbacks. This requries to implement the callback system by ourselves instead of syscall's NewCallback.
pureffi supports this, it even has a test case for this scenario, TestFullCircleFFI
Activity
TotallyGamerJet commentedon Apr 21, 2024
My comment applies here too
JupiterRider commentedon Apr 26, 2024
Here is a first example of how it could look like:
judah-caruso commentedon Aug 18, 2025
I'd like to take a crack at this. I have a windows machine (amd64) and a macbook (arm64 with Rosetta), so I can properly test and maintain this.
I'm assuming this involves moving
struct_amd64.go/struct_arm64.gotostruct_darwin_amd64.go/struct_darwin_arm64.go(with appropriate build tags), then creating a newstruct_windows_amd64.go. If that's the case, I'd just need to writeaddStruct+ others that comply with Microsoft's x64 calling conventions?I'm most definitely missing something, so let me know!
TotallyGamerJet commentedon Aug 18, 2025
That should pretty much be it. Idk if the amd64 windows ABI needs any special registers like arm64 did so that might complicate. Also I think that arm64 windows should have the same ABI as macOS so those can be shared
judah-caruso commentedon Aug 18, 2025
Sounds good! I don’t think I’ll be able to test arm64 windows (unless there’s an easy emulator I can utilize). Would you rather me leave it out or include it in the build tags (+ add it to the CICD pipeline)?
unxed commentedon May 28, 2026
Check this. Should solve your problem due to specifics of underlyting ffi engine.
https://github.com/unxed/pureffi
hajimehoshi commentedon Jun 16, 2026
Apparently, it's not difficult to fix purego to pass structs, but it's quite difficult to treat structs in callbacks. This requries to implement the callback system by ourselves instead of syscall's NewCallback.
unxed commentedon Jun 16, 2026
pureffi supports this, it even has a test case for this scenario, TestFullCircleFFI
hajimehoshi commentedon Jun 16, 2026
It's because goffi is used as the backend, right?
purego: support structs on Windows amd64/arm64
purego: support structs on Windows amd64/arm64
purego: support structs on Windows amd64/arm64
purego: support structs on Windows amd64/arm64
purego: support structs on Windows amd64/arm64
purego: support structs on Windows amd64/arm64
purego: support structs on Windows amd64/arm64
purego: support structs on Windows amd64/arm64 (#465)