From: Eric Moss
Subject: Lispworks: passing strings in FLI
Date: 
Message-ID: <3A08786D.A0D28E38@everest.com>
Hi,

I am trying to call a Unix C library routine that takes a char* as an
argument. It was painless in Allegro, but I see no examples of doing so
in Lispworks (the Windows example doesn't help), and the documentation
is lacking. Can someone post an example (both the FLI
define-foreign-function and an example of calling it)? Thanks! (please
email the example to me, in case my newsreader dies again).

Eric

From: Lieven Marchand
Subject: Re: Lispworks: passing strings in FLI
Date: 
Message-ID: <m3snp2pe7m.fsf@localhost.localdomain>
Eric Moss <····@everest.com> writes:

> Hi,
> 
> I am trying to call a Unix C library routine that takes a char* as an
> argument. It was painless in Allegro, but I see no examples of doing so
> in Lispworks (the Windows example doesn't help), and the documentation
> is lacking. Can someone post an example (both the FLI
> define-foreign-function and an example of calling it)? Thanks! (please
> email the example to me, in case my newsreader dies again).

CL-USER 10 > (fli:define-foreign-function (c-string-length "strlen")
                ((string (:pointer (:unsigned :char))))
              :result-type :int
              :language :ansi-c)
C-STRING-LENGTH

CL-USER 11 > (fli:with-foreign-string (pointer ignored-1 ignored-2) 
                "Dit is een test!"
              (c-string-length pointer))
16

HTH

-- 
Lieven Marchand <···@bewoner.dma.be>
Lambda calculus - Call us a mad club
From: Kent M Pitman
Subject: Re: Lispworks: passing strings in FLI
Date: 
Message-ID: <sfwy9yui3qf.fsf@world.std.com>
Lieven Marchand <···@bewoner.dma.be> writes:

> CL-USER 10 > (fli:define-foreign-function (c-string-length "strlen")
>                 ((string (:pointer (:unsigned :char))))
>               :result-type :int
>               :language :ansi-c)
> C-STRING-LENGTH

Gee, wouldn't this be a lot clearer and prettier if the language were 
case-sensitive so you could omit those two ugly doublequotes?  In fact,
I bet you could just directly call strlen without even a 
define-foreign-function declaration and all those result type
and language thingies if only you could call strlen in its intended case...

Sorry, couldn't resist just a touch of humor. ;-)