chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] foreign functions, swig


From: felix winkelmann
Subject: Re: [Chicken-users] foreign functions, swig
Date: Sat, 20 May 2006 23:06:32 +0200

On 5/20/06, Dan <address@hidden> 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




reply via email to

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