[plt-scheme] FFI and byte-strings

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Feb 3 06:46:47 EST 2007

On Feb  3, Jens Axel Søgaard wrote:
> Hi all,
> Is there a way to go from a byte-string to a pointer
> to the beginning of the c-array, where the actual bytes
> are stored?

A byte string can be used whenever you need a pointer:

in "x.c":

  int foo(char *a) {
    return a[0]+a[1]+a[2];

And in mzscheme:

  > ((get-ffi-obj 'foo "x.so" (_fun _pointer -> _int)) #"\1\2\3")

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

Posted on the users mailing list.