[plt-scheme] Binding C-Structs Containing Fixed-Size Arrays with the FFI
2009/1/26 Matthew Flatt <mflatt at cs.utah.edu>:
> I would define `dVector3' as a structure:
>
> (define _dReal _float)
> (define-cstruct _dVector3 ([v0 _dReal] [v1 _dReal]
> [v2 _dReal] [v3 _dReal]))
>
> Defining a cstruct type doesn't work well for large arrays, but I bet
> it will work well in this case.
Thanks for the reply! That would work well in this case, but perhaps I
should have thrown out the tougher problem first:
typedef dReal dMatrix3[4*3];
//...
struct dMass {
dReal mass;
dVector4 c;
dMatrix3 I;
//...
}
It would be awkward to define and use dMatrix3 as a struct in this
case, and with my limited C implementation knowledge it's not clear to
me that the alignment would be the same.
Henk