 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Wen Guest
|
Posted: Fri Aug 12, 2005 2:27 am Post subject: can cppbuilder invoke microsoft visuall cpp class which incl |
|
|
as i know, cppbuilder can invoke extern "C" __stdcall api of vc dll, but i
wanna invoke c++ class of vc dll?
is there any way to this goal?
any help would be greatly appreciated.
with my best regards,
Wen
|
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Fri Aug 12, 2005 3:54 am Post subject: Re: can cppbuilder invoke microsoft visuall cpp class which |
|
|
"Wen" <wenming_hu2002 (AT) hotmail (DOT) com> wrote
| Quote: | as i know, cppbuilder can invoke extern "C" __stdcall api of vc dll, but
i
wanna invoke c++ class of vc dll?
is there any way to this goal?
|
AFAIK, you'd have to write your class in the dll like this:
#ifdef IS_THE_DLL
#define CLASS_DECLARATION __declspec(dllexport)
#else
#define CLASS_DECLARATION __declspec(dllimport)
#endif
class CLASS_DECLARATION MyClass
{
....
Then you'd need to write a function like this inside the dll:
extern "C" __declspec(dllexport) MyClass* CreateMyClass() { return new
MyClass; }
Finally define IS_THE_DLL when building the DLL, otherwise undef it for
using the DLL in BCB.
HTH
Jonathan
|
|
| Back to top |
|
 |
Wen Guest
|
Posted: Fri Aug 12, 2005 4:24 am Post subject: Re: can cppbuilder invoke microsoft visuall cpp class which |
|
|
"Jonathan Benedicto" <incorrect (AT) no (DOT) server>
:42fc1d69 (AT) newsgroups (DOT) borland.com...
| Quote: | "Wen" <wenming_hu2002 (AT) hotmail (DOT) com> wrote in message
news:42fc0906 (AT) newsgroups (DOT) borland.com...
as i know, cppbuilder can invoke extern "C" __stdcall api of vc dll, but
i
wanna invoke c++ class of vc dll?
is there any way to this goal?
AFAIK, you'd have to write your class in the dll like this:
#ifdef IS_THE_DLL
#define CLASS_DECLARATION __declspec(dllexport)
#else
#define CLASS_DECLARATION __declspec(dllimport)
#endif
class CLASS_DECLARATION MyClass
{
...
Then you'd need to write a function like this inside the dll:
extern "C" __declspec(dllexport) MyClass* CreateMyClass() { return new
MyClass; }
Finally define IS_THE_DLL when building the DLL, otherwise undef it for
using the DLL in BCB.
|
why do i need write extern "C" __declspec(dllexport) MyClass*
CreateMyClass() { return new MyClass; }?
so how do i invoke the C++ class of vc dll? do the same things as invoking
C++ class of vc dll in vc?
Thank you
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Aug 12, 2005 8:22 am Post subject: Re: can cppbuilder invoke microsoft visuall cpp class which |
|
|
"Wen" <wenming_hu2002 (AT) hotmail (DOT) com> wrote
| Quote: | why do i need write extern "C" __declspec(dllexport)
MyClass* CreateMyClass() { return new MyClass; }?
|
The point Jonathan is trying to make is that you cannot directly use vc++
classes from Borland compilers, so you have to flatten the access into
C-style functions that do the work for you, and then you can access the
functions instead.
| Quote: | so how do i invoke the C++ class of vc dll?
|
You cannot.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|