Solved

static STL objects in MFC extension DLLs

Posted on 1997-07-31
5
389 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:stuthulhu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Expert Comment

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

0
 

Author Comment

by:stuthulhu
ID: 1302973
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.)
0
 
LVL 3

Expert Comment

by:vinniew
ID: 1302974
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?
0
 

Author Comment

by:stuthulhu
ID: 1302975
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.
0
 
LVL 2

Accepted Solution

by:
anichini earned 220 total points
ID: 1302976
This Knowledge Base article proposes two workarounds to your problem:

http://www.microsoft.com/kb/articles/q172/3/96.htm

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question