[gambit-list] How to pass a u8vector to the FFI

Marc Feeley feeley at iro.umontreal.ca
Tue Mar 30 10:39:35 EDT 2010


On 2010-03-30, at 10:34 AM, Alex Queiroz wrote:

>     I always use ___FETCH_U* with a C integer as the second argument,
> i. e., I don't use the ___INT() conversion macro.

Indeed the ___INT(x) macro converts the fixnum x into a C int.  It is the inverse of the ___FIX(n) macro which converts a C int into a fixnum.

The simplest way to do what you want is:

char *u8vectorptr = ___CAST(char*,___BODY(theu8vectorschemeobjectvariable));

then

u8vectorptr[i] = ...;

Note that you can only do this if the u8vector will not move (it is either a ___STILL or ___PERM object, or you don't make any calls back to Scheme or the Gambit memory allocator inside your C function.

Marc




More information about the Gambit-list mailing list