On 5/20/06, Dan <[EMAIL PROTECTED]> wrote:
Hi all,I'm trying to create bindings for a large library (GSL, which is not so popular these days for some reason) as painlessly as possible. Ideally, I would write no declarations by hand, just some #include's. I have tried two approaches: 1) Using SWIG: %module gsl %{ #include <gsl/gsl_rng.h> } %include <gsl/gsl_rng.h> This works, but swig has some smart type-checking that prevents me from passing srfi-4 f64vector's instead of (double *). I don't know how to convert between the two in Scheme either. 2) Using Chicken #>! extern void gsl_sort (double *v, size_t s, size_t N); <# This works with f64vector's, but will be verbose. If I just place the #include between #>! and <#, it doesn't get parsed. So I'd have to write lots of extern's. A further problems is that if I pass plain vector's instead of f64vector's, csi crashes, but I guess I can live with that. Is there an optimal solution?
Well, interfacing to foreign code (especially large libraries) is never much fun. I recommend using SWIG and writing special typemaps for converting double*'s to f64vectors. The SWIG manual explains how this is done - alternatively I can try, if you can wait a few days. cheers, felix _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
