Lisp HUG Maillist Archive

Passing floats to FLI functions not working

This must be something incredibly simple (read: stupid on my part),
but I've getting near my whit's end, and I was hoping someone could
give me a good push in the right direction...

I'm using LWW 4.3.7 and I've been using the FLI with other packages
(successfully) for quite some time. But now I'm putting together my
own DLL to use with LW and everything is working except for floating
point values. The functions work on the C side (I've tested them
extensively), so I know that isn't it.

Finally, today, I modified one of my functions to display a message
box that shows all floating point parameters that are being passed to
the function. They are all 0.0. No matter what type I use in the FLI
(:float, :double, :lisp-float, :lisp-single-float, ...) they all get
passed to the function as 0.0. Everything else works (strings,
integers, booleans, etc), just not floats.

If it helps, all functions in the DLL are __cdecl, and the :float
types work with the OpenGL FLI interface that I put together on my web
site. Heh, I don't know if that's a comfort or just adds more to the
frustration.

Thanks in advance for any advice and suggestions,

Jeff M.

-- 
http://www.retrobyte.org
mailto:massung@gmail.com

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


Re: Passing floats to FLI functions not working

I saw exactly same problem, all float values were equal to 0.0 for my DLL
functions. Solution was to pass floats by pointer or to return as structure
memeber, it was sad since I should allocate float wrapper before call. Now I
am not working with that library and simply forget about the problem, but
AFAIK it is still here.

Lisper.

----- Original Message -----
From: "Jeff Massung" <massung@gmail.com>
To: <lisp-hug@xanalys.com>
Sent: Sunday, May 08, 2005 11:07 PM
Subject: Passing floats to FLI functions not working


> This must be something incredibly simple (read: stupid on my part),
> but I've getting near my whit's end, and I was hoping someone could
> give me a good push in the right direction...
>
> I'm using LWW 4.3.7 and I've been using the FLI with other packages
> (successfully) for quite some time. But now I'm putting together my
> own DLL to use with LW and everything is working except for floating
> point values. The functions work on the C side (I've tested them
> extensively), so I know that isn't it.
>
> Finally, today, I modified one of my functions to display a message
> box that shows all floating point parameters that are being passed to
> the function. They are all 0.0. No matter what type I use in the FLI
> (:float, :double, :lisp-float, :lisp-single-float, ...) they all get
> passed to the function as 0.0. Everything else works (strings,
> integers, booleans, etc), just not floats.
>
> If it helps, all functions in the DLL are __cdecl, and the :float
> types work with the OpenGL FLI interface that I put together on my web
> site. Heh, I don't know if that's a comfort or just adds more to the
> frustration.
>
> Thanks in advance for any advice and suggestions,
>
> Jeff M.
>
> --
> http://www.retrobyte.org
> mailto:massung@gmail.com
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
>


Re: Passing floats to FLI functions not working

 
| Finally, today, I modified one of my functions to display a message
| box that shows all floating point parameters that are being passed to
| the function. They are all 0.0. No matter what type I use in the FLI
| (:float, :double, :lisp-float, :lisp-single-float, ...) they all get
| passed to the function as 0.0. Everything else works (strings,
| integers, booleans, etc), just not floats.

You don't show your C function prototypes.
One way to get this trouble is to have C expect float and not
specify :language :ansi-c to fli:define-foreign-function.
If you use :language :c, then LW will put a double-float on the
stack probably resulting in a zero value seen by C as well as
having any additional parameters messed up.

Paul



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


Updated at: 2020-12-10 08:52 UTC