[CM] s7 wrap c func with scheme

James Hearon j_hearon at hotmail.com
Fri Feb 24 10:26:18 PST 2017


Hi,

I had a question about wrapping a c func with scheme, s7.

I'm trying to understand how to wrap the declared function from the .h file with scheme in a .scm file (mywrapper.scm) so that it can be called from s7 and use the shared library.

> (load mywrapper.scm)
> (myfunction)
> (exit)


I have a .c file which includes a function (myfunction), and .h which declares that function.
I compile the .c file using -fpic into an obj. file, then create a shared library, ex. mylib.so.

I'm looking at SND files libc.scm and libgsl.scm which seem to be wrappers, but are quite complicated.  I'm also looking at the S7 manual example for "Load a shared library", but there are static s7_pointer functions in the example's c code which seem to be doing the wrapping on the c side as opposed to wrapping a c function in scheme using a .scm file.

I'm wondering if there's a simpler example somplace where I can get some ideas about how to go about wrapping a c function in scheme, or if the manual vers. is the preferred way to go, i.e. create a library using s7 functions from c, and then load the library into s7 to call the function?

Regards,
Jim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20170224/03507c2d/attachment.html>


More information about the Cmdist mailing list