Access an STL object through a pointer or reference in a different DLL or EXE

M

mos

Hi!

According the article:
You may experience an access violation when you access an STL object
through a pointer or reference in a different DLL or EXE
http://support.microsoft.com/default.aspx?scid=kb;en-us;172396
But I wonder which stl object can access and which not, I have used
std::iostream and std::string this way and seems ok, I know std::map can
not, is there any more? The question confused me much.

Best regard
mos.
 
A

ablock84

Hi!

According the article:
You may experience an access violation when you access an STL object
through a pointer or reference in a different DLL or EXEhttp://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b172396
But I wonder which stl object can access and which not, I have used
std::iostream and std::string this way and seems ok, I know std::map can
not, is there any more? The question confused me much.

Best regard
mos.

I'm using the stl between dll's and exe's all the time. You have to
watch out which runtime library you link. In Visual Studio you have to
check it in "Code Generation". It must be one of the DLL versions.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

I'm using the stl between dll's and exe's all the time. You have to
watch out which runtime library you link. In Visual Studio you have to
check it in "Code Generation". It must be one of the DLL versions.

For the app, the DLL or both?
 
M

mos

Hi!
I test the article's example, dll use /MTd exe use /MLd but no access
violation occur, but I indeed meet such things.
according to reason in the aticle:

Most classes in the Standard C++ Libraries use static data members directly
or indirectly. Since these classes are generated through template
instantiation, each executable image (usually with DLL or EXE file name
extensions) will contain its own copy of the static data member for a given
class. When a method of the class that requires the static data member is
executed, it uses the static data member in the executable image in which
the method code resides. Since the static data members in the executable
images are not in sync, this action could result in an access violation or
data may appear to be lost or corrupted.

seems reasonable, so I'am still confused
 
D

Dennis \(Icarus\)

mos said:
Hi!

According the article:
You may experience an access violation when you access an STL object
through a pointer or reference in a different DLL or EXE
http://support.microsoft.com/default.aspx?scid=kb;en-us;172396
But I wonder which stl object can access and which not, I have used
std::iostream and std::string this way and seems ok, I know std::map can
not, is there any more? The question confused me much.

Are you using either Visual C++ 5.0 or 6.0?

This was fixed in VS 2003.

Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top