[gambit-list] Structs in FFI

Will Donnelly will.donnelly at gmail.com
Thu Jul 24 23:02:30 EDT 2008


Recently (this morning) I began using Gambit Scheme, and so far it has
been a wonderful language to work with.  I like doing graphical stuff,
so I'm trying to use Gambit's FFI to interface with the SDL libraries.
 I've gotten everything to work so far, compiling and linking with
libSDL from within gsc properly, but now I have two questions.

One, is there any way to specify, in comments or some such, what
compiler and linker flags a file should have in a call to
compile-file?  I'm using emacs as an editor, and the C-c C-k command
is useless, since the file won't get linked to libSDL like it needs
to.  This is really only a minor issue though, as

(begin (compile-file "sdl-test" ld-options: "-lSDL") (load "sdl-test"))

is not too hard to use.

Two, am I missing something when it comes to interfacing with C
structs?  The only references that I've found
(http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Using_Gambit_with_External_Libraries)
and (http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html#SEC135)
seem to contain horrendously complex code for something as simple as
accessing a struct like

typedef struct SDL_Rect {
	Sint16 x, y;
	Uint16 w, h;
} SDL_Rect;

from within Scheme.  Does anyone with more experience than I have some
pointers on how to do this?



More information about the Gambit-list mailing list