Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / float isn't returning right! in VS C++ 2008

Author
Message
G T R
18
Years of Service
User Offline
Joined: 26th Apr 2005
Location: Dubai, UAE
Posted: 5th Jun 2008 14:53
I am using VS C++ 2008

the code in C++:


String Table:


DBP code:


Output:
start test
15
20
1082340096

as you can see the float should be 4.1
but it's returned 1082340096
what Iam doing wrong?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jun 2008 14:56
Ah, you mean that you aren't returning floats right.

ADD TWO FLOATS[%DFF%?Add_Two_Floats@@YAKMM@Z

should be

ADD TWO FLOATS[%FFF%?Add_Two_Floats@@YAKMM@Z

jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 5th Jun 2008 15:04 Edited at: 5th Jun 2008 15:06
ADD TWO FLOATS[%FFF%?Add_Two_Floats@@YAKMM@Z

You still tell DBPro that the return type is a float. It is VC++ that you are trying to deceive.

IanM...Sorry, I'm doing too many things at once this morning.
G T R
18
Years of Service
User Offline
Joined: 26th Apr 2005
Location: Dubai, UAE
Posted: 5th Jun 2008 15:11
ahaaa ... now i got the idea
thank you guys
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Jun 2008 20:15
I know that you have to cast it to dword, but surely it makes no difference because it the same actual data, just in a different type. Are floats returned in a special way or something?

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 5th Jun 2008 20:57 Edited at: 5th Jun 2008 20:57
Usually a float is returned in the ST(0) register (with the cdecl calling convention), but DBP expects them in EAX.

Login to post a reply

Server time is: 2024-04-24 16:49:31
Your offset time is: 2024-04-24 16:49:31