Calling a function inside a DLL

new topic     » topic index » view thread      » older message » newer message

I have a very simple function inside a DLL (CalcCircle.dll) built using MingW32 written in C:

double DLL_EXPORT CalcArea(const double r) 
{ 
 return r*r*3.14159; 
} 

I tried to call this function (CalcArea) from Euphoria using the code below but i get as result 0. What am I missing? Thank you. PS 1. I tried to call this function using code in Delphi (Object Pascal) and C and it works. 2. I have changed the calling convenction from "cdecl" to "stdcall" but the result remains the same (0.00000).

-- Euphoria code 
 
include dll.e 
include std/machine.e 
 
atom  
  CalcCircleDll, Area 
   
integer PID 
 
CalcCircleDll = open_dll("CalcCircle.dll") 
if CalcCircleDll = 0 then 
    puts(2, "Sorry. Couldn't find <CalcCircle.Dll>\n") 
end if 
 
PID = define_c_func(CalcCircleDll, "CalcArea", {C_FLOAT}, C_FLOAT) 
printf(1, "PID = %d\n", PID) 
 
Area = c_func(PID, {10.0}) 
 
printf(1, "Area = %f", Area) 
-- gives 0.00000 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu