[plt-scheme] define-cstruct, mutual dependency

From: Robert Nikander (nikander at nc.rr.com)
Date: Tue Oct 23 23:02:52 EDT 2007


I'm trying to work with two C structs that use each other in their  
definitions.  I don't see a way to define this with `define-cstruct'.

struct Object {
     Class *isa;
struct Class : Object {
     const char *name;

This doesn't work, because I can't mention one before the other:

(define-cstruct _Object ([isa _Class-pointer]))
(define-cstruct (_Class _Object) ([name _string] ...)

I'd like to declare the inheritance relation so I can pass classes to  
functions that expect objects.

Any ideas?


Posted on the users mailing list.