Lisp HUG Maillist Archive

FLI Foreign Callable with string argument

Hello All,

 

I’m having some trouble figuring out how to define a foreign callable that takes a string argument. The C prototype is below. Any help would be greatly appreciated.

 

void callback(void  (*func)(char *));

 

Thanks,

Gerry

 

 

 

Re: FLI Foreign Callable with string argument

I'm away from the computer ATM, but I'm pretty sure it'd be something like this:

(define-foreign-callable (my-function "my_function" :void)
    ((str (:reference :ef-mb-string)))
  (print str))

If the :reference doesn't work then just use (:pointer :char) and convert in the body:

(let ((s (convert-from-foreign-string str)))
  (print s))

Is that what you needed?

Jeff M.

Sent from my iPad

On Nov 24, 2013, at 7:13 PM, Gerry Weaver <gerryw@compvia.com> wrote:

Hello All,

 

I’m having some trouble figuring out how to define a foreign callable that takes a string argument. The C prototype is below. Any help would be greatly appreciated.

 

void callback(void  (*func)(char *));

 

Thanks,

Gerry

 

 

 

Updated at: 2020-12-10 08:34 UTC