Solved

static STL objects in MFC extension DLLs

Posted on 1997-07-31
5
381 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 54
fizzArray2 challenge 1 71
either24  challenge 19 90
abstract class with all non abstract mentods 6 75
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now