Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

static STL objects in MFC extension DLLs

Posted on 1997-07-31
5
Medium Priority
?
391 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 440 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 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