Plugins ... again

Started by
2 comments, last by _DarkWIng_ 20 years, 6 months ago
Hi! I''ve got another problem. Now I have no problem exporting single simple classes from DLL, but I need something more. I have a base class like this:

class CBase {
public:
  virtual void DoStuff() = 0;
  //... other virtual functions
protected
  // for simplicity I have just soem static int.. 
  // in real code there is another class here
  static int count;
}
 
Then I have a derived class in DLL. All was nice until I added that static member. The point is that this static is only shared among instances of derived class of this DLL and not in general (I have other classes derived from CBase in my project)... Any idea how to fix this so static member would be shared among all? Now problem #2. Static member is not a simple int. It''s quite a big class. It calls functions from engine core (uses resource managers, loaders,...). Any way to avoid including all related stuff to this class in DLL? I hope anyone understands what I''m trying to do here.. ps : sorry for all the typos. You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Advertisement
I have no idea if this will work, but its the first thing that came into my head. In your DLL... I assume you just declared the static data member globally. Maybe if you declare it globally in the rest of the program, two copies are made (one for DLL.. one for rest of program)... perhaps if you declared it extern in the rest of the program, the dlls version might be used. Just a suggestion anyway.
To keep from having to include everything, make the static member a pointer, and before the definition of CBase. Then, in your DLL code, initialize the pointer. Oh, and I think allocating memory can be a problem with DLLs, so that may be a problem as well.
dmounty: I had a simmilar idea at first but then somehow filed to actualy make it work as it should.

zaniwhoop2: I tought about it too. I have to solve problem #1 so I can even try this. But memory allocation will probably be a problem.

Thanks for input. If anyone else has any ideas/experiance how to handle this please post.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement