[CM] On FFI bindings

bil at ccrma.Stanford.EDU bil at ccrma.Stanford.EDU
Thu Oct 22 10:16:33 PDT 2020

It looks like init_args can work:

tlib.c (using linux below):

#include <stdio.h>
#include <stdlib.h>
#include "s7.h"

static s7_pointer a_function(s7_scheme *sc, s7_pointer args)

void tlib_init(s7_scheme *sc, s7_pointer args);
void tlib_init(s7_scheme *sc, s7_pointer args)
   fprintf(stderr, "tlib_init: %s\n", s7_object_to_c_string(sc, args));
   s7_define_function(sc, "a-function", a_function, 0, 0, true, "");

gcc -fPIC -c tlib.c
gcc tlib.o -shared -o tlib.so -ldl -lm -Wl,-export-dynamic

/home/bil/cl/ repl
<1> (load "tlib.so" (inlet 'init_func 'tlib_init 'init_args (list 1 2 
tlib_init: (1 2 3)
<2> (a-function 1 2 3)

I think you'll need to remember which form you're using -- if you
call the no-args init func with args or vice versa, all bets are off.

More information about the Cmdist mailing list