From: David Richards

Subject: Re: Foreign Function Interface Question

Date: 2001-2-25 17:34

Hello All,
   Again, this has to do with the Foreign Function Interface for Allegro 
6.0:
   Actually I'm answering my own question here - I simply redefined my 
function as follows:

  (ff:def-foreign-call (tst-string "tststring") ((s (* :char)))
  :returning ((* :char) string))

And things began to work - I can't say why they work - I really don't 
have a solid grasp of the syntax here. I'm just using the "force" so to 
speak and hacking  things from the Documentation.  But my next question 
is does anyone know how to define a lisp method that is expecting an 
array of strings from the called 'C' function.  I tried the following 
but with out any success:

(ff:def-foreign-call (tst-string "tststring") ((s (* :char) string))
    :returning (( * ( * :char)) (simple-array simple-string(*) ))) 

I copied this from the docs as well except the documentation was 
explaining how to send an array of strings.
Any info would be helpful...
Dave



David Richards wrote:

> I have a question having to do with the foreign Function Interface. I > defined a 'C' function as follows: > char *tststring(char *s); > > I compiled the code and made a shared library out of it (I'm on a > Linux system). Then in lisp I loaded it with: > (load "libtststring.so") > > And then using the Foreign Function interface I created my lisp > function for calling it as follows: > > (ff:def-foreign-call (tst-string "tststring") ((s (* :char) string)) > :returning ((* :char) string)) > > Now the string that is returned to me by my function call is correct > but the string that is being passed into my 'C' function is not. When > I enter the 'C' function I am only seeing the first character of the > string I am trying to pass to it ( I have confirmed this by having > included some debugging code). I tried to redefine my lisp function > as follows but still with out success: > > (ff:def-foreign-call (tst-string "tststring") ((s (* :char) > with-native-string)) ;; doesn't work either! > :returning ((* :char) string)) > > Can someone give me some insight as to what I am doing wrong? > Many thanks! > Dave Richards