[plt-scheme] Binding C-Structs Containing Fixed-Size Arrays with the FFI

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Jan 26 15:36:22 EST 2009

On Jan 26, Jakub Piotr C?apa wrote:
> You may want to check these threads:
> http://thread.gmane.org/gmane.lisp.scheme.plt/12987
> http://thread.gmane.org/gmane.lisp.scheme.plt/28412/focus=28509
> http://list.cs.brown.edu/pipermail/plt-scheme/2007-March/016671.html

The quick version is: libffi doesn't have a way to do so.  You need to
either fake it with structs like Matthew showed, or you can do it more
manually: malloc a piece of memory and `ptr-ref' parts of it directly.
But that won't work inside a struct -- I don't know of any API in
libffi to create a type with a given size/alignment.

> PS. Some mention in the documentation would probably help (this is a FAQ 
> with a big *F*).

It is, but I don't see how to add it...

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.