[plt-scheme] FFI and byte-strings
Eli Barzilay skrev:
> 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")
> 6
That simple!
For the record: the new FFI is brilliant.
Thanks,
--
Jens Axel Søgaard