RE: STL Containers and __declspec(export/import)

"Bryan Wagstaff" <[email protected]> Sun, 6 Feb 2005 16:47:09 -0700
Newsgroups gmane.games.devel.windows
Message-ID <000301c50ca6$31a1a9f0$0200000a@starlight>
Your guess is correct.

Exporting the STL containers is a Bad Thing(tm).

Implementations of the STL are not necessarily binary compatible.  There is
no convenient way to translate between different implementations, so if the
DLL uses a different version than your executable, the objects will differ
and your program will fail.

Vectors are a special case.  The latest versions of the C++ standard have a
guarantee that vectors are contiguous, and all major implementations before
that guarantee also have that behavior, so passing vectors around as general
arrays can be done safely.

I seem to remember also that the VC++ 7.1 uses local storage in the
implementation, so in that case, even moving between the same implementation
would fail if you crossed EXE/DLL boundaries.

Hope that explains things a bit.

Bryan.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Chris
Raine
Sent: Sunday, February 06, 2005 3:26 PM
To: [email protected]
Subject: [GD-Windows] STL Containers and __declspec(export/import)

Hi, 

If you stick a STL container to a class with __declspec(export) vcc will
whine about the STL container not being declared with __declspec(export)
attribute. What I found after a bit of doc-digging was that MSDN
suggests that you explicitly instantiate the STL container with
'extern'. 

Having done that and still having no success with getting around the
annoying warning, I found out that the same MSDN-document had a very
small note stating :

<quote> 
"The only STL container that can currently be exported is vector. The
other containers (that is map, set,queue, list, deque) all contain
nested class and [therefore] cannot be exported."
<quote/>

The document I'm referring to is entitled "Howto: Exporting STL
Components Inside & Outside of a Class" and was last updated on
5-7-2001. Has there been any update on this topic for Studio .Net 2003
(which is what I am using) that I could not find?

Am I correct with guessing that using the STL container classes in
external header files of a dll is a no-no and should be avoided?
Ignoring that warning would be dangerous (for I do not like the concept
of fixing problems by disabling the warnings they create).

confused and thanking for any insight given regarding this topic, 
Chris 





-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_idU5