Open Apis035 opened 3 months ago
Yes, apparently clang has around 12,000+ lines of gymnastics to get around this problem.
The structs are passed differently for each architecture and os. Sometimes, values are passed in vector registers, sometimes in integer registers (even if the value is a float), sometimes combining multiple floats into a single integer register, sometimes breaking structs into multiple "args" which are passed as registers, sometimes returning structures by out pointers, sometimes passing some fields in one way and others in another, and lots more. And all of this is architecture and os dependent.
I've been looking at different ways to handle this, but it might be awhile as you can probably understand, given that it will require thousands of lines of nonsensical magic.
...And may crash the program. But passing by reference does work properly.
While passing struct by value:
Example C library:
Adept:
Test case
Related issue to discussion #337. Luckily, that problem can be resolved because the 4 ubyte struct is packed into a single int.