[plt-scheme] FFI, argc and argv

From: Paulo J. Matos (pocm at soton.ac.uk)
Date: Sun May 6 11:20:21 EDT 2007

On 5/6/07, Eli Barzilay <eli at barzilay.org> wrote:
> On May  6, Paulo J. Matos wrote:
> > Hello all,
> >
> > If I have a function in C that receives int argc, and char **argv,
> > what's the best way to warp it up?
> >
> > Two issues come to my mind:
> > - command-line-arguments do not provide, afaik, argv[0].
>
> No, that's the reason for `-C'.
>

What do you mean by this? (I'm probably missing something, is that a flag?)

>
> You don't even need to convert the vector to a list because _vector
> does that:
>
>   (define main
>     (get-ffi-obj "main" "x.so"
>       (_fun (v) :: (_int = (vector-length v)) ((_vector i _string) = v)
>             -> _void)))
>   (main '#("j" "k" "l"))
>
>

If I pass (command-line-arguments) as the vector and the function
expects argv[0] to be name of the program, "j" will have to be it,
right?

Cheers,

Paulo Matos

> --
>           ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                   http://www.barzilay.org/                 Maze is Life!
>
>
>


-- 
Paulo Jorge Matos - pocm at soton.ac.uk
http://www.personal.soton.ac.uk/pocm
PhD Student @ ECS
University of Southampton, UK


Posted on the users mailing list.