
James Bielman <jamesjb@jamesjb.com> writes:
Frank Goenninger <fgoenninger@prion.de> writes:
I do habe C structs lile these:
struct a_struct { int a; };
struct b_struct { int b; struct a_struct a; };
How would I model b_struct using defcstruct ?
It looks like what you would think:
(defcstruct a-struct (a :int))
(defcstruct b-struct (b :int) (a a-struct))
I should add that another potentially confusing thing here is when you access the A slot of a B-STRUCT, you get back a pointer to it, instead of the A-STRUCT by value. For example: (foreign-slot-value b 'b-struct 'b) -> 100 ; an int (foreign-slot-value b 'b-struct 'a) -> #<pointer ...> ; a pointer Probably this DWIM-ish behavior was also a mistake, and you should use FOREIGN-SLOT-POINTER to access the structure instead (which does work now): (foreign-slot-value b 'b-struct 'a) -> error! (foreign-slot-pointer b 'b-struct 'a) -> #<pointer ...> James