[cffi-devel] Calling Lisp Function from C: How to declare this function in C land ?

Frank Goenninger frgo at me.com
Sat Sep 22 19:27:37 UTC 2012


(also posted to comp.lang.lisp)

Hi all:

I have a lisp image that contains the following functions:

(defun frgo (a)
  (format *debug-io* "~%~A~&" a)
  (values))

(cffi:defcallback frgo_helper :void ((a-cstr :string))
  (frgo (cffi:foreign-string-to-lisp a-cstr)))

In a C dynamic library I have:

* file frgo_c.h:

extern void frgo_helper( char * a );

* file frgo_c.c:

void frgo( char * a )
{
  frgo_helper( a );
}

Now, the library does not compile - undefined symbol _frgo_helper() ! 

How do I make functions "known" to C land that are purely defined as
callbacks in Lisp land? 

I tried to declare the function in C land like this:
 
extern void frgo_helper( char * a ) __attribute__((weak_import));

No luck, though. My environment is:

Mac OS X Snow Leopard (10.6.8), Apple LLVM compiler 3.0. 

An ideas / hints / tipps? Thanks a lot!

Cheers

  Frank




More information about the cffi-devel mailing list