[gambit-list] FFI float/int interoperability?

Pierre-Alexandre Fournier pafournier at gmail.com
Sat Dec 23 10:38:54 EST 2006


Hi,

see the C-interface documentation for type equivalence:
http://www.iro.umontreal.ca/~gambit/doc/gambit-c_19.html#SEC126

If you want to send a float as an int to a c-lambda, you can convert
it with (inexact->exact (round x)). To send an integer as a float, use
(exact->inexact x).

Cheers,

Pierre-Alexandre


2006/12/23, TJ <tjay.dreaming at gmail.com>:
> Is there a way to make Gambit behave like C when passing floats/ints
> to and from foreign functions? I mean to have them automatically
> converted as they would be if I were programming in C.
>
> I've run into a problem where I have 2 variables (in Scheme) to keep
> track of my OpenGL window's width and height, but the calls to OpenGL
> expect floats (gluOrtho2D) while the calls to SDL expects ints
> (SDL_SetVideoMode).
>
> If there isn't a way to convert automatically, is there a Scheme
> function to convert between these two types? I suppose I could write
> them myself, but since I'm already asking...
>
> TJ
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>



More information about the Gambit-list mailing list