Link to home
Start Free TrialLog in
Avatar of chiarelli
chiarelli

asked on

DLL 16bits creation for Excel use

I need to build a basic DLL: f(x)=x*x in Borland 4.52 in W31
I call this DLL from a Visual Basic macro in Excel5 to get
the result of the calculation.
I know how to call this DLL from Excel, but I don't know how to create the DLL in Borland.
For the moment my .cpp file contains:
#include <windows.h>
extern double _export FAR test_calc (double x);

double FAR _export test_calc (double x)
{
return x*x;
}

int FAR PASCAL LibMain (HANDLE, WORD, WORD, WORD, LPSTR)
{
return 1;
}
But the macro returns:"Not definied function in the specified DLL" (I know the Visual Basic macro is correct).

Is the .cpp file correct to idenfiy the entry variable and
to return this simple result ?
Avatar of chensu
chensu
Flag of Canada image

Since your file name is *.cpp, you should use C linkage.

extern "C" double _export FAR test_calc (double x);

extern "C" double FAR _export test_calc (double x)
                  {
                  return x*x;
                  }
Avatar of chiarelli
chiarelli

ASKER

This answer does not resolve the problem.
The question is still the same.
Thanks

ASKER CERTIFIED SOLUTION
Avatar of meinn
meinn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial