[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C structures

From: klaus schilling
Subject: Re: C structures
Date: Fri, 30 Dec 2005 20:45:34 +0100

Leonardo Lopes Pereira writes:
 > To be more clear. I want to be able to call a C function from guile.
 > The problem is that this function has a struct as an arg and this
 > struct has variable members. So, I need to create a list on
 > scheme/guile and convert it to a C struct that will be used as an arg
 > to that function.

one can add another smob type that actually holds a pointer to the struct.
this works well if the interface of the strcut is controlled by the C API.
Smobs also provide for garbage collection mechanism,
which is a problem in hand-woven conversions from structured C data to 
Scheme data. Most C libraries iontroducing struct arguments essentially
define the struct and functions to handle pointers of that struct,
including allocation functions , freeing functions, copying etc.
These need to be plugged into the definition of a smob type.
Jim Blandy wrote a manual for that almost 10 years ago,
coming with the guile dists.
Nowadays, the gh_ interface is deprecated, so one should
switch to scm_ interface in non-heritage projects

Klaus Schilling

reply via email to

[Prev in Thread] Current Thread [Next in Thread]