[plt-scheme] ffi equivalent of array in struct

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Sun Apr 23 20:34:41 EDT 2006

Is there an equivalent type in ffi to the array member of a struct in C?

Something like
struct foo{
  int blah[ 10 ];
};

Im creating objects that I dont want the GC to see so I use (malloc 
'raw) but I have to give the size of the entire object to malloc as 
opposed to this:

(let ((f (malloc 'raw _Foo))
   (set-Foo-blah! f (malloc 'raw _int 10)))

Obviously this doenst work but its sort of annoying to precalculate the 
size of the struct in C and use that as the size argument to malloc in 
scheme. Im guessing the way to do this is some trickery with the _bytes 
type? Is there some way I can specify the size of a member when 
declaring a C-struct? If not, that would be nice :).

(define-cstruct _Foo)
   ((blah (_bytes 10)))


Posted on the users mailing list.