chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Some pointers on easyffi and interfacing with C code


From: John Cowan
Subject: Re: [Chicken-users] Some pointers on easyffi and interfacing with C code
Date: Fri, 11 Jan 2008 00:41:05 -0500
User-agent: Mutt/1.5.13 (2006-08-11)

Mark Fredrickson scripsit:

> 1. Many of the GEOS functions return 'char', even though the actual  
> data should be a bool. Is there a way to tell easyffi to treat these  
> characters as #t/#f? I'm thinking there might be a __declare() for it,  
> but I didn't see anything that made immediate sense to me.
> 
> 2. Several of the functions return ints to represent success, errors,  
> and take a "return" argument by reference. Is there a best practice  
> for dealing with these kinds of functions? Here's an example if I'm  
> not being clear (the goal is to compute the length of a "geometry"  
> e.g. a line):

The general answer in both cases is to wrap the raw C function in a
Scheme function that provides a more sensible interface.  That takes
care of #1.  As for #2, Scheme can return multiple values, unlike C,
so you can pass back both the status and the return argument.

-- 
Here lies the Christian,                        John Cowan
        judge, and poet Peter,                  http://www.ccil.org/~cowan
Who broke the laws of God                       address@hidden
        and man and metre.




reply via email to

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