Returning a string from a LISP callable

Myrosia Dzikovska <[email protected]> Thu, 22 Oct 2009 15:20:49 +0100
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
Hello,

I am trying to put together an application in ACL 8.0 where a C++
server periodically calls into LISP (I am integrating with a C++
communications library). It needs to pass a string (char*) argument
into LISP, and return a string (char*) as well.

I can make the callables that pass in a string to LISP, and return
nothing, work. But I cannot return a string sensibly.

So far, I have tried a :returning declaration in
defun-foreign-callable, and setting the convert-to-c-types parameter
in register-foreign-callable to t. In both cases, a null pointer was
returned. I also tried setting a global LISP variable to the return
string value, and accessing it with lisp_value from C. I could not
figure out how the macros in lisp.h work, so the several combinations
I have tried either don't compile, or return a segmentation violation.

If someone could provide me with an example of how this can be done, I
would very much appreciate it.

Myrosia