[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] noobie question about chicken/swig/csi
From: |
minh thu |
Subject: |
Re: [Chicken-users] noobie question about chicken/swig/csi |
Date: |
Mon, 2 Apr 2007 10:36:47 +0200 |
2007/4/2, Tato Norren <address@hidden>:
Hi,
I feel like an idiot asking, but what exactly are the sequence of
commands needed to make the following C function callable from the
chicken interpretor? on Linux.
//test.c
double test(double x){
return x * x;
}
//test.i
%module test
%{
double test(double);
%}
thanks,
tato
Hi,
For simple things like that, don't use swig.
In a .scm file, write this:
(define test
(foreign-lambda double "test" double))
'test' is the name in Scheme.
"test" is the name in C.
The first double is the return type.
The last double is the arg.
Compile the .scm and the .c files together with csc -s.
Note the -s whiwh will make a shared library : a .so file.
Now assuming the file were called tt.*, you can bring the function in csi with
csi -require-extension tt
or calling (require-extension tt) from a script.
For more complete explanation, see here:
http://chicken.wiki.br/Interface to external functions and variables
There is another way : just use the declaration of your function with
foreign-parse, it will automatically make it available in Scheme.
Use the Search Box and your left on
http://chicken.wiki.br/.
Cheers,
thu
- [Chicken-users] noobie question about chicken/swig/csi, Tato Norren, 2007/04/02
- Re: [Chicken-users] noobie question about chicken/swig/csi,
minh thu <=
- Re: [Chicken-users] noobie question about chicken/swig/csi, Graham Fawcett, 2007/04/02
- Re: [Chicken-users] noobie question about chicken/swig/csi, Alex Queiroz, 2007/04/02
- Re: [Chicken-users] noobie question about chicken/swig/csi, minh thu, 2007/04/02
- Re: [Chicken-users] noobie question about chicken/swig/csi, Alex Queiroz, 2007/04/02
- Re: [Chicken-users] noobie question about chicken/swig/csi, Graham Fawcett, 2007/04/02
- Re: [Chicken-users] noobie question about chicken/swig/csi, Alex Queiroz, 2007/04/02
- Re: [Chicken-users] noobie question about chicken/swig/csi, Graham Fawcett, 2007/04/02