|
From: | Shawn Rutledge |
Subject: | Re: [Chicken-users] return a float from foreign function |
Date: | Sun, 27 Aug 2006 23:46:22 -0700 |
On 8/27/06, John Cowan <address@hidden> wrote:
Shawn Rutledge scripsit: > impl.c: > > #include <math.h> > > float baz(int i) > { > return (((float)i) / 15.2); > } Note that "float" in Chicken foreign types is a synonym for "double", whereas "float" in C means single-float and "double" means double-float. So you need to change the C code to say "double" in both place in order to get this to work at all (except by luck).
That doesn't seem to be enough. double baz(int i) { return (double)i / 2.35; } (define baz (foreign-lambda float "baz" int)) (display baz) (display (baz 42)) ./callit #<procedure (baz a25)>42.0
[Prev in Thread] | Current Thread | [Next in Thread] |