Is it possible to load a shared library in ECL, import some C functions which receive and return cl_object (as if they were defined with ecl_def_c_function()) and invoke them in REPL (without compiling a *.lisp file)?
For example:
// file 'extensions.c' compiled to 'extensions.so'
cl_object
do_something
(cl_object arg)
{
cl_object
result = ...;
return result;
}
; in ECL REPL
(uffi:load-foreign-library #p".../extensions.so")
... ; importing stuff
(format t "got: ~a~%" (do-something "text"))
As I found there's no way of telling ECL (via UFFI) that C functions deal with cl_object, not a regular pointer (void*).
Looks like you can't do it as easy as in Python. The only solution I found so far:
extlib.c
Compile it:
load-extlib.lisp
Compile it:
Load & test it: