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 / Call Dll with Float As Int

Author
Message
KuRiX
17
Years of Service
User Offline
Joined: 27th Jan 2007
Location:
Posted: 2nd Feb 2007 14:16
Hi.

I have created a dll, that takes 2 float parameters and returns one float.

The problem is that if i call the dll with 2 integers instead of floats, there is no automatic casting... and the result is wrong...

I think this is a problem because i must be very carefull when calling the dll.

I use load dll and call dll.

Any help?, thanks

No pain, no gain.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 2nd Feb 2007 16:29
doesnt the dll code cast the arguments to floats?
like if you pass in 9 from dbp code, wouldnt the dll treat it as 9.0F ?

can you post the dbp code that makes the call, and some of the dll code (func def) might help too.

Michael Moore needs this film:Aaron Russo's America: Freedom To Fascism
RonPaul'08
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 2nd Feb 2007 16:38
When you use CALL DLL the parameters are kind of a variant type as it has no way to determine what parameter types the DLL function expects. So it can't cast the type automatically.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2007 18:48
To state what Empty said another way, it's your responsibility to ensure that the correct data type is passed to your DLL.

The safest way I've found to do this is to ensure that you don't call your DLL function directly, but wrap it in a small function that has the correct parameter types, and call that function instead. That way, the values are cast to the correct type automatically.

KuRiX
17
Years of Service
User Offline
Joined: 27th Jan 2007
Location:
Posted: 3rd Feb 2007 01:11
I like the wrapping method, thanks. I only hope that this will not affect speed too much. Thanks !

No pain, no gain.

Login to post a reply

Server time is: 2024-11-22 17:15:13
Your offset time is: 2024-11-22 17:15:13