[racket] Bootstrapping an FFI

From: Ian Tegebo (ian.tegebo at gmail.com)
Date: Fri Aug 10 22:43:45 EDT 2012

I'm playing around with an FFI for SDL.  Rather than slog through all
the headers by hand, I went looking for some code that may do a bit of
the parsing and translation.  On PLaneT, I found dherman's c.plt:

http://planet.racket-lang.org/display.ss?package=c.plt&owner=dherman

I got stuck when it appeared that I'd need to provide it with a list
of symbols that were typedef-ed:

http://planet.racket-lang.org/package-source/dherman/c.plt/4/0/planet-docs/c/parsing.html#(part._include)

I bit of preprocessing seems to make this still quite a bit of work:

gcc  -D "__extension__=" -D "__attribute__(ARGS)=" -E
/usr/include/SDL/SDL.h  | sed '/^\#/d' | indent -st -i2 |grep -vE
'^[[:space:]]*$' > sdl.h

Has anyone else gone down this road before?  Also, Besides Eli's
paper, any general advice for Racket FFIs?

Thanks,
-- 
Ian Tegebo

Posted on the users mailing list.