2007/4/2, Tato Norren <[EMAIL PROTECTED]>:
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 mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
