From: Ulrich Drepper
Subject: char*[] in FFI for Allegro
Date: 
Message-ID: <r2ra1fvzc4.fsf@happy.cygnus.com>
Hi,

Does anybody know how to call a function like

	int foo (char *v[], int n)

from ACL5.0beta using the new FFI?  The HTML documentation coming with
ACL5.0beta suggests

  (def-foreign-call foo ((v (* * :char) (simple-array simple-string (*))) n))

but seems not to work

  Error: don't know how to convert type: (* * :char)


One can denote a simple string using (* :char) but the notation for an
array of strings above is not understood.  Anybody have a solution?
This is on Linux in case it works for somebody on another platform.

Thanks,

-- Uli
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

From: Steve Gonedes
Subject: Re: char*[] in FFI for Allegro
Date: 
Message-ID: <6kj5j6$m4t@bgtnsc03.worldnet.att.net>
Ulrich Drepper <·······@cygnus.com> writes:

< 
< Hi,
< 
< Does anybody know how to call a function like
< 
< 	int foo (char *v[], int n)
< 
< from ACL5.0beta using the new FFI?  The HTML documentation coming with
< ACL5.0beta suggests
< 
<   (def-foreign-call foo ((v (* * :char) (simple-array simple-string (*))) n))
< 
< but seems not to work
< 
<   Error: don't know how to convert type: (* * :char)
< 
< 
< One can denote a simple string using (* :char) but the notation for an
< array of strings above is not understood.  Anybody have a solution?
< This is on Linux in case it works for somebody on another platform.


I got it to work by just using the (* :char) notation. Don't know if
it was intended to work this way or if there are any adverse side
effects.

(ff:def-foreign-call find_name
       ((names (* :char) (simple-array simple-string (*)))
        (n :int fixnum))
    :returning :int)

The new FF interface seems to have gotten a bit complicated. I like
the older interface which will still work in acl5 (but it has to load
a backwards-compatibility-module).

The older interface (v4.3) looked like this.

(ff:defforeign 'find-name
   :entry-point "find_name"
   :arguments '((simple-array simple-string (*)) integer)
   :return-type :integer)

I'm still using libc-1 (I am too scared to switch to libc2 - that
elf/a.out incident still has me shaken up).

Anyway, hope this helps some...
From: Ulrich Drepper
Subject: Re: char*[] in FFI for Allegro
Date: 
Message-ID: <r2iumqwi8l.fsf@happy.cygnus.com>
Steve Gonedes <········@worldnet.att.net> writes:

> I got it to work by just using the (* :char) notation. Don't know if
> it was intended to work this way or if there are any adverse side
> effects.

This works, thanks a lot.  Somebody from Franz want to comment on this?

-- Uli
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------
From: Jim Veitch
Subject: Re: char*[] in FFI for Allegro
Date: 
Message-ID: <356EFC19.6E7@franz.com>
Ulrich Drepper wrote:
> 
> Steve Gonedes <········@worldnet.att.net> writes:
> 
> > I got it to work by just using the (* :char) notation. Don't know if
> > it was intended to work this way or if there are any adverse side
> > effects.
> 
> This works, thanks a lot.  Somebody from Franz want to comment on this?
> 
> -- Uli


We have a bug in our beta documentation fspec50.htm.

(def-foreign-call c_array ((str (* * :char) (simple-array simple-string
(*))) ...

This should be instead:

(def-foreign-call c_array ((str (* (* :char)) (simple-array
simple-string (*))) ...

Our syntax did get somewhat more complex because it got closer to C. 
However, one can specify more C-like things than formerly.