[r6rs-discuss] Chez Scheme FFI question: returning structs

Aaron W. Hsu arcfide at sacrideo.us
Wed Apr 28 23:09:59 EDT 2010


Hey Ed,
 
Fortunately, I can help you here:
 
> Using the Chez Scheme FFI, what's a good way to bind to a C function 
> which returns a struct? Maybe I missed something in the docs, but it 
> doesn't appear to be straightforward.
> 
> For example, take a look at 'gsl_matrix_view_array':
> 
> http://www.gnu.org/software/gsl/manual/html_node/Matrix-views.html
> 
> gsl_matrix_view
> gsl_matrix_view_array (double * base, size_t n1, size_t n2)
> 
> The type 'gsl_matrix_view' is a struct.

I have gone through this before when I created my sockets library. The
best advice I can give you is to see how I used ffi-bind (a library I
wrote) and the FFI system on Chez Scheme to get the sockets code to
deal nicely with the structures. You can grab it from the latest
Arctic Repository release, or you can grab it from my monotone server.

  gopher://gopher.sacrideo.us/1arcrep
 
I hope that helps! You can see lots of examples of how I deal with
foreign structs in that code.
 
    Aaron W. Hsu



More information about the r6rs-discuss mailing list