<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[std vector als member in]]></title><description><![CDATA[<p>hi ich möchte ein projekt als dll übersetzen.<br />
in dem projekt gibt es eine klasse, die einen vector benutzt.</p>
<p>das hat probleme bereitet und ich habe folgendes gefunden:<br />
<a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;q168958" rel="nofollow">http://support.microsoft.com/default.aspx?scid=kb;EN-US;q168958</a></p>
<blockquote>
<p>#include &lt;vector&gt;</p>
<p>// Provide the storage class specifier (extern for an .exe file, null<br />
// for DLL) and the __declspec specifier (dllimport for .an .exe file,<br />
// dllexport for DLL).<br />
// You must define EXP_STL when compiling the DLL.<br />
// You can now use this header file in both the .exe file and DLL - a<br />
// much safer means of using common declarations than two different<br />
// header files.<br />
#ifdef EXP_STL<br />
# define DECLSPECIFIER __declspec(dllexport)<br />
# define EXPIMP_TEMPLATE<br />
#else<br />
# define DECLSPECIFIER __declspec(dllimport)<br />
# define EXPIMP_TEMPLATE extern<br />
#endif</p>
<p>// Instantiate classes vector&lt;int&gt; and vector&lt;char&gt;<br />
// This does not create an object. It only forces the generation of all<br />
// of the members of classes vector&lt;int&gt; and vector&lt;char&gt;. It exports<br />
// them from the DLL and imports them into the .exe file.<br />
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector&lt;int&gt;;<br />
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector&lt;char&gt;;</p>
<p>// Declare/Define a class that contains both a static and non-static<br />
// data member of an STL object.<br />
// Note that the two template instantiations above are required for<br />
// the data members to be accessible. If the instantiations above are<br />
// omitted, you may experience an access violation.</p>
</blockquote>
<p>danach habe ich meinen code umgeschrieben.<br />
jetzt sieht er so aus:</p>
<pre><code class="language-cpp">//dll export/import
#ifdef MY_BUILD_DLL
 #define DLL __declspec(dllexport)
 //help4templateexport
 #define DLL_TEMPLATE
#else
 #define DLL __declspec(dllimport)
 //help4templateexport
 #define DLL_TEMPLATE extern
#endif
DLL_TEMPLATE template class DLL std::vector&lt;int&gt;;

  class DLL Testklasse{

public:
 std::vector&lt;int&gt; a;
};
</code></pre>
<p>allerdings bekomme ich beim kompilen immer folgende ausgaben:</p>
<pre><code>1&gt;  bcHelperfunctions.cpp
1&gt;d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val&lt;_Ty,_Alloc&gt;::_Alval': class 'std::allocator&lt;_Ty&gt;' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val&lt;_Ty,_Alloc&gt;' verwendet wird
1&gt;          with
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::vector&lt;_Ty&gt;&quot;.
1&gt;          with
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;  Code wird generiert...
1&gt;  Kompilieren...
1&gt;  test.cpp
1&gt;d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val&lt;_Ty,_Alloc&gt;::_Alval': class 'std::allocator&lt;_Ty&gt;' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val&lt;_Ty,_Alloc&gt;' verwendet wird
1&gt;          with
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::vector&lt;_Ty&gt;&quot;.
1&gt;          with
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;  bcLogfile.cpp
1&gt;d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val&lt;_Ty,_Alloc&gt;::_Alval': class 'std::allocator&lt;_Ty&gt;' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val&lt;_Ty,_Alloc&gt;' verwendet wird
1&gt;          with
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::vector&lt;_Ty&gt;&quot;.
1&gt;          with
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;  Code wird generiert...
</code></pre>
<p>ganz am ende bekomme ich aber diese meldung:</p>
<blockquote>
<p>========== Erstellen: 1 erfolgreich, Fehler bei 0, 0 aktuell, 0 übersprungen ==========</p>
</blockquote>
<p>soll ich das jetzt ignorieren?<br />
was muss ich machen um diese warnungen loszuwerden?(ich will sie nicht einfach unterdrücken)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/279382/std-vector-als-member-in</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 16:23:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/279382.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Dec 2010 09:45:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std vector als member in on Sat, 25 Dec 2010 09:45:04 GMT]]></title><description><![CDATA[<p>hi ich möchte ein projekt als dll übersetzen.<br />
in dem projekt gibt es eine klasse, die einen vector benutzt.</p>
<p>das hat probleme bereitet und ich habe folgendes gefunden:<br />
<a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;q168958" rel="nofollow">http://support.microsoft.com/default.aspx?scid=kb;EN-US;q168958</a></p>
<blockquote>
<p>#include &lt;vector&gt;</p>
<p>// Provide the storage class specifier (extern for an .exe file, null<br />
// for DLL) and the __declspec specifier (dllimport for .an .exe file,<br />
// dllexport for DLL).<br />
// You must define EXP_STL when compiling the DLL.<br />
// You can now use this header file in both the .exe file and DLL - a<br />
// much safer means of using common declarations than two different<br />
// header files.<br />
#ifdef EXP_STL<br />
# define DECLSPECIFIER __declspec(dllexport)<br />
# define EXPIMP_TEMPLATE<br />
#else<br />
# define DECLSPECIFIER __declspec(dllimport)<br />
# define EXPIMP_TEMPLATE extern<br />
#endif</p>
<p>// Instantiate classes vector&lt;int&gt; and vector&lt;char&gt;<br />
// This does not create an object. It only forces the generation of all<br />
// of the members of classes vector&lt;int&gt; and vector&lt;char&gt;. It exports<br />
// them from the DLL and imports them into the .exe file.<br />
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector&lt;int&gt;;<br />
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector&lt;char&gt;;</p>
<p>// Declare/Define a class that contains both a static and non-static<br />
// data member of an STL object.<br />
// Note that the two template instantiations above are required for<br />
// the data members to be accessible. If the instantiations above are<br />
// omitted, you may experience an access violation.</p>
</blockquote>
<p>danach habe ich meinen code umgeschrieben.<br />
jetzt sieht er so aus:</p>
<pre><code class="language-cpp">//dll export/import
#ifdef MY_BUILD_DLL
 #define DLL __declspec(dllexport)
 //help4templateexport
 #define DLL_TEMPLATE
#else
 #define DLL __declspec(dllimport)
 //help4templateexport
 #define DLL_TEMPLATE extern
#endif
DLL_TEMPLATE template class DLL std::vector&lt;int&gt;;

  class DLL Testklasse{

public:
 std::vector&lt;int&gt; a;
};
</code></pre>
<p>allerdings bekomme ich beim kompilen immer folgende ausgaben:</p>
<pre><code>1&gt;  bcHelperfunctions.cpp
1&gt;d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val&lt;_Ty,_Alloc&gt;::_Alval': class 'std::allocator&lt;_Ty&gt;' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val&lt;_Ty,_Alloc&gt;' verwendet wird
1&gt;          with
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::vector&lt;_Ty&gt;&quot;.
1&gt;          with
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;  Code wird generiert...
1&gt;  Kompilieren...
1&gt;  test.cpp
1&gt;d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val&lt;_Ty,_Alloc&gt;::_Alval': class 'std::allocator&lt;_Ty&gt;' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val&lt;_Ty,_Alloc&gt;' verwendet wird
1&gt;          with
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::vector&lt;_Ty&gt;&quot;.
1&gt;          with
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;  bcLogfile.cpp
1&gt;d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val&lt;_Ty,_Alloc&gt;::_Alval': class 'std::allocator&lt;_Ty&gt;' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val&lt;_Ty,_Alloc&gt;' verwendet wird
1&gt;          with
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;          and
1&gt;          [
1&gt;              _Ty=int,
1&gt;              _Alloc=std::allocator&lt;int&gt;
1&gt;          ]
1&gt;          g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::vector&lt;_Ty&gt;&quot;.
1&gt;          with
1&gt;          [
1&gt;              _Ty=int
1&gt;          ]
1&gt;  Code wird generiert...
</code></pre>
<p>ganz am ende bekomme ich aber diese meldung:</p>
<blockquote>
<p>========== Erstellen: 1 erfolgreich, Fehler bei 0, 0 aktuell, 0 übersprungen ==========</p>
</blockquote>
<p>soll ich das jetzt ignorieren?<br />
was muss ich machen um diese warnungen loszuwerden?(ich will sie nicht einfach unterdrücken)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998757</guid><dc:creator><![CDATA[endenz]]></dc:creator><pubDate>Sat, 25 Dec 2010 09:45:04 GMT</pubDate></item><item><title><![CDATA[Reply to std vector als member in on Sat, 25 Dec 2010 10:36:29 GMT]]></title><description><![CDATA[<p>Meinst du nicht, das die MSDN Hilfe nicht auch schlau genug ist? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p><a href="http://msdn.microsoft.com/en-us/library/esew7y1w.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/esew7y1w.aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998763</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998763</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Sat, 25 Dec 2010 10:36:29 GMT</pubDate></item><item><title><![CDATA[Reply to std vector als member in on Sat, 25 Dec 2010 10:50:09 GMT]]></title><description><![CDATA[<p>also ja.<br />
ich denke dann mal das trifft auch auf ofsteams zu</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1998766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1998766</guid><dc:creator><![CDATA[endenz]]></dc:creator><pubDate>Sat, 25 Dec 2010 10:50:09 GMT</pubDate></item></channel></rss>