BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

can cppbuilder invoke microsoft visuall cpp class which incl

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Wen
Guest





PostPosted: Fri Aug 12, 2005 2:27 am    Post subject: can cppbuilder invoke microsoft visuall cpp class which incl Reply with 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?

any help would be greatly appreciated.

with my best regards,
Wen


Back to top
Jonathan Benedicto
Guest





PostPosted: Fri Aug 12, 2005 3:54 am    Post subject: Re: can cppbuilder invoke microsoft visuall cpp class which Reply with quote



"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





PostPosted: Fri Aug 12, 2005 4:24 am    Post subject: Re: can cppbuilder invoke microsoft visuall cpp class which Reply with quote




"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
Quote:

HTH

Jonathan




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Aug 12, 2005 8:22 am    Post subject: Re: can cppbuilder invoke microsoft visuall cpp class which Reply with quote


"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.