[gambit-list] c-struct

Eduardo Cavazos wayo.cavazos at gmail.com
Wed May 23 05:48:23 EDT 2007


Hello,

I defined a macro named c-struct to help with interfacing to C structs.

Let's say you have a C struct:

typedef struct {
    int x;
    int y;
} point ;

This expression:

(c-struct point ((x int) (y int)))

Expands into the code to generate these functions:

make-point
point-x
point-y
set-point-x!
set-point-y!

Here's the macro:

http://dharmatech.onigirihouse.com/scheme/c-struct.scm

The problem is, I'm not sure how to integrate it with Gambit-C. :-)

I've tried a few variations but the compiles fail, I think due to improperly 
including syntax-case.

One place I'd like to use it is to extend Xlib.scm. I'd like to use c-struct 
to generate code for the X event structs.

One problem is that c-struct is a syntax-case macro.

Do I stick (include "~~/syntax-case") in "c-struct.scm"?

"c-struct.scm" depends on "srfi-28.scm". So do I (include "srfi-28.scm") as 
well?

Finally, should I put (include "c-struct") in "Xlib.scm"?

Thanks for any suggestions.

Ed



More information about the Gambit-list mailing list