Link to home
Start Free TrialLog in
Avatar of stuthulhu
stuthulhu

asked on

static STL objects in MFC extension DLLs

I have an extension DLL class which contains a static STL map object:

class AFX_EXT_CLASS SomeDLLClass
{
      static map<int,int> sm_SomeMap;
      //etc.
};

Within an application I try to make a copy of this object:

map<int,int> localMap(SomeDllClass::sm_SomeMap);

This causes a crash inside STL.  (In fact, it often causes Developer Studio to crash as well.)  My theory is that STL's internal static objects (such as _Tree<...>::_Nil) are not working properly across the extension DLL/app boundary, but I am having trouble generating a piece of test code that convinces me that I completely understand the problem.

Has anybody else already dealt with this problem?  Are some STL classes off limits within MFC extension DLLs?
Avatar of yonat
yonat

Get a better STL implementation from:
http://www.ipmce.su/~fbp/stl/

Avatar of stuthulhu

ASKER

I will try the more recent STL implementation, but if it relies on class statics at all, it is going to have the same problem.  (Upon further testing I have convinced myself that class statics do not export correctly, even in a simple, non-STL scaffold.)
anything defined as static *can't* be exported in VC.  That's one of the reasons people use static.  It's part of the definition.  Are you really talking about exporting a static function?
No, I am talking about exporting a class which has a data member which is the instantiation of some template.  The template class, in turn, has one or more static data members.  See the sample code.
ASKER CERTIFIED SOLUTION
Avatar of anichini
anichini

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial