chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Returning f32vectors in C for Chicken's FFI


From: felix winkelmann
Subject: Re: [Chicken-users] Returning f32vectors in C for Chicken's FFI
Date: Mon, 3 Jan 2005 12:46:13 +0100

On Sun, 02 Jan 2005 03:05:17 -0500, Pierre-Alexandre Fournier
<address@hidden> wrote:
> Hi,
> 
> I'm new to Chicken and its FFI. I'm trying to make a C function return a
> f32vector when called in Scheme. A f32vector is translated in float*
> when passed to C. I would like to know how to cast this float* in f32vector.
> 

Well, you can use the "___declare(type, ...)" pseudo declaration to
define a transformation procedure that turns the returned
ptr back into a f32vector, but that wouldn't know the size of
the result. I think the cleanest solution would be to write a wrapper
procedure around your  f32add procedure that takes the length
of the arguments, allocates a result vector and passes that to
the foreign procedure, which in turn then mutates it. The user
of the wrapper would then get a fresh vector.


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]