chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Passing floats to and from foreign functions


From: pluijzer .
Subject: [Chicken-users] Passing floats to and from foreign functions
Date: Sun, 12 May 2013 02:14:34 +0200

Hello everybody,
I'm having trouble passing floating point numbers to and from foreign functions.

This is what I'm doing:

-- test.scm --

(require-extension easyffi)
(print ((foreign-lambda float "testGet")))
((foreign-lambda void "testSet" float) 4.0)
(print ((foreign-lambda float "testGet")))

-- wrapper.c --

float a = 5.0;
void testSet(float value) { a = value; }
float testGet(void) { return a; }

What I get is this:

> csc -X easyffi wrapper.c test.scm
> ./test
-1080529876.0
-1080533140.0

But I expected the output to be:
4.0
5.0

I'm I doing something wrong/forgetting something?
When I use integers instead of floats I do get the desired result.

Thank you in advance,
Righard


reply via email to

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