char*[] in FFI for Allegro 
Author Message
 char*[] in FFI for Allegro

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   `------------------------



Sun, 12 Nov 2000 03:00:00 GMT  
 char*[] in FFI for Allegro

<
< 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...



Mon, 13 Nov 2000 03:00:00 GMT  
 char*[] in FFI for Allegro

Quote:

> 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   `------------------------



Mon, 13 Nov 2000 03:00:00 GMT  
 char*[] in FFI for Allegro

Quote:


> > 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.



Tue, 14 Nov 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Franz Allegro Common Lisp 6.0: FFI

2. some clear examples for FFI call to a Windows api function in Franz Allegro for Windows

3. Allegro FFI to GL/OpenGL??

4. ACL6.0 / ACL5 issue w FFI char*

5. Object comment do: [:char | char yourself]

6. reversing lines char by char, but not the line order in a file

7. How to read line char by char?

8. CHAR and [CHAR]

9. ASCII vs. CHAR [CHAR]

10. CHAR with ARRAY OF CHAR assignment compatible ?

11. CHAR with ARRAY OF CHAR assignment compatible ?

12. write-char vs. display-char

 

 
Powered by phpBB® Forum Software