float args in c ffi

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

float args in c ffi

Ian Martins
float arguments to c functions aren't acting the same as they did in
version 2.02.

this used to work:
---
var f : Float = 2;
cfunction(f); // where f must be a float
---
now it fails at runtime in the c function, claiming that f isn't a
float.  type() says its a float, and casting it to a float doesn't help.

this works:
---
var f = 2.0;
cfunction(f); // where f must be a float
---



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: float args in c ffi

Nicolas Cannasse
Ian Martins a écrit :

> float arguments to c functions aren't acting the same as they did in
> version 2.02.
>
> this used to work:
> ---
> var f : Float = 2;
> cfunction(f); // where f must be a float
> ---
> now it fails at runtime in the c function, claiming that f isn't a
> float.  type() says its a float, and casting it to a float doesn't help.

There has been no change in Neko related to that.
If you want to accept both int and float, you can use the "number" type
check(arg,number) and val_number(arg).

Nicolas

--
haXe - an open source web programming language
http://haxe.org