*Owen Wengerd
Message 11 of 12 (73 Views)

Re: how to access static variable in DBX

12-28-2007 11:37 PM in reply to: nk_klein
> I'm confused again. how can import class from the DLL
> which doesn't export that class?

You should *not* import (or export) the class. Remove the 'CALLEE_API'
from the class declaration in Callee.h, then change your macro definitions
#define CALLEE_API __declspec(dllexport)
#define CALLEE_API __declspec(dllimport)

Once this is done, you can define fnCallee in Calle.cpp like this:
int fnCallee(void)
return CCallee::s_nCount;

In Caller.cpp, you cannot construct a CCallee object on the stack. If you
could, CCallee's vtable would reside in Caller's address space. That is the
problem that arises when you export the class, and it's the reason you
should not export the class. Instead, call an exported function that
returns a new CCallee that is constructed in CCallee's module. Declare this
function in CCallee.h:

CALLEE_API CCallee* ConstructCallee(void);

Define the function in Callee.cpp:

CCallee* ConstructCallee(void)
return new CCallee;

In Caller.cpp, call that function:
CCallee* pNewCallee = ConstructCallee();

Now you have a new CCallee, and it was constructed with its vtable in the
CCallee module's address space. If you need to call CCallee member
functions from CCaller, then you should either make those member functions
virtual; or export a non-member helper function from the CCallee module that
accepts a CCallee* argument, calls its member function, then returns the

I hope this helps. :smileyhappy:
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
Posts: 13
Registered: ‎09-19-2007
Message 12 of 12 (73 Views)

Re: how to access static variable in DBX

12-31-2007 10:04 PM in reply to: nk_klein
you're so kind! I understand
Thank you very very much!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.