chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] return a float from foreign function


From: Shawn Rutledge
Subject: [Chicken-users] return a float from foreign function
Date: Sun, 27 Aug 2006 02:31:03 -0700

impl.c:

#include <math.h>

float baz(int i)
{
       return (((float)i) / 15.2);
}

callit.scm:

(define baz (foreign-lambda float "baz" int))
(display baz)
(display (baz 42))

csc callit.scm impl.c

./callit
#<procedure (baz a25)>42.0

Change impl.c to make sure it's being called at all:

#include <math.h>
#include <stdio.h>

float baz(int i)
{
       printf("baz given %d\n", i);
       return (((float)i) / 15.2);
}

./callit
#<procedure (baz a25)>baz given 42
13.0

This is with chicken 2.2 and I think 2.3 also has similar problems.  I
can try 2.41 when it gets done building.




reply via email to

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