Click to See Complete Forum and Search --> : Using VC++ generated DLLs in Borland C++ 5.0


Rajesh L
May 16th, 1999, 10:56 PM
Hi All,

I'm trying to create DLL in VC++ 6.0 with the follwing spec :

extern "C"
{
int _pascal _export MyFunc(char *szSomeData);
}

Since VC++ environment doesn't support _pascal or _export keywords any more, I cannot compile my project.

I'm using these keywords because one of our application was written in Borland C++ and I must use the above DLL with it.

Brief : Can I create a DLL / LIB in VC++ that can be used in BC++ environment.

Please do help me in this.

Thanks in advance.

Playman Cheng
May 17th, 1999, 04:55 AM
Use the PASCAL and EXPORT keywords instead.

Rajesh L
May 18th, 1999, 02:33 AM
Hi Cheng,

Thank you.

I tried to use PASCAL and EXPORT keywords, but that doesn't work either.
Specifically, I can't use EXPORT keyword. Please suggest.

Best regards,
Rajesh

Playman Cheng
May 21st, 1999, 11:43 PM
I used these keywords as following:
extern "C" BOOL PASCAL EXPORT DrawInit(int* nX,int* nY)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); //if you use MFC
}
Add the function name to the EXPORTS section of the .def file.
It works well.I don't know what your matter really is, so I can't give you any more valuable
ideas.

Gomez Addams
May 22nd, 1999, 05:17 PM
Try this :

extern "C"
{
int _stdcall __declspec(dllexport) MyFunc(char *szSomeData);
}

Gomez Addams
May 22nd, 1999, 05:21 PM
Try this :

extern "C"
{
int _stdcall __declspec(dllexport) MyFunc(char *szSomeData);
}

This will export as _MyFunc@4 unless you use a .def file
If you use a header file to give the appropriate prototype
you shouldn't have a problem.

Paul McKenzie
May 23rd, 1999, 03:19 AM
You are not defining the exported function correctly. The _export keyword is not used in a 32-bit environment. That's why VC++ ignores it.

If you are building a 32-bit DLL, there should be no problem in defining the functions as this:

#ifdef DLL
#define FUNCDEF __declspec( dllexport ) __stdcall
#else
#define FUNCDEF __stdcall
#endif

extern "C" {
BOOL FUNCDEF MyFunc(int);
}

This works in both Borland and Microsoft. Just define the DLL symbol if you are compiling the DLL.

Regards,

Paul McKenzie