By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

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

P: n/a
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...en-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.
Mar 19 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Mar 19, 9:23 am, "mos" <mmosqu...@163.comwrote:
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.

Mar 19 '07 #2

P: n/a
On 19 Mar, 13:02, abloc...@googlemail.com wrote:
On Mar 19, 9:23 am, "mos" <mmosqu...@163.comwrote:
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.
For the app, the DLL or both?

--
Erik Wikström

Mar 19 '07 #3

P: n/a
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

<ab******@googlemail.com>
??????:11*********************@l77g2000hsb.googleg roups.com...
On Mar 19, 9:23 am, "mos" <mmosqu...@163.comwrote:
>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.

Mar 20 '07 #4

P: n/a
"mos" <mm*******@163.comwrote in message
news:et**********@news.yaako.com...
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...en-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.
Are you using either Visual C++ 5.0 or 6.0?

This was fixed in VS 2003.

Dennis
Apr 1 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.