std vector als member in
-
hi ich möchte ein projekt als dll übersetzen.
in dem projekt gibt es eine klasse, die einen vector benutzt.das hat probleme bereitet und ich habe folgendes gefunden:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q168958#include <vector>
// Provide the storage class specifier (extern for an .exe file, null
// for DLL) and the __declspec specifier (dllimport for .an .exe file,
// dllexport for DLL).
// You must define EXP_STL when compiling the DLL.
// You can now use this header file in both the .exe file and DLL - a
// much safer means of using common declarations than two different
// header files.
#ifdef EXP_STL
# define DECLSPECIFIER __declspec(dllexport)
# define EXPIMP_TEMPLATE
#else
# define DECLSPECIFIER __declspec(dllimport)
# define EXPIMP_TEMPLATE extern
#endif// Instantiate classes vector<int> and vector<char>
// This does not create an object. It only forces the generation of all
// of the members of classes vector<int> and vector<char>. It exports
// them from the DLL and imports them into the .exe file.
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector<int>;
EXPIMP_TEMPLATE template class DECLSPECIFIER std::vector<char>;// Declare/Define a class that contains both a static and non-static
// data member of an STL object.
// Note that the two template instantiations above are required for
// the data members to be accessible. If the instantiations above are
// omitted, you may experience an access violation.danach habe ich meinen code umgeschrieben.
jetzt sieht er so aus://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<int>; class DLL Testklasse{ public: std::vector<int> a; };allerdings bekomme ich beim kompilen immer folgende ausgaben:
1> bcHelperfunctions.cpp 1>d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val<_Ty,_Alloc>::_Alval': class 'std::allocator<_Ty>' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val<_Ty,_Alloc>' verwendet wird 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> and 1> [ 1> _Ty=int 1> ] 1> and 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::vector<_Ty>". 1> with 1> [ 1> _Ty=int 1> ] 1> Code wird generiert... 1> Kompilieren... 1> test.cpp 1>d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val<_Ty,_Alloc>::_Alval': class 'std::allocator<_Ty>' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val<_Ty,_Alloc>' verwendet wird 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> and 1> [ 1> _Ty=int 1> ] 1> and 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::vector<_Ty>". 1> with 1> [ 1> _Ty=int 1> ] 1> bcLogfile.cpp 1>d:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(481): warning C4251: 'std::_Vector_val<_Ty,_Alloc>::_Alval': class 'std::allocator<_Ty>' erfordert eine DLL-Schnittstelle, die von Clients von class 'std::_Vector_val<_Ty,_Alloc>' verwendet wird 1> with 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> and 1> [ 1> _Ty=int 1> ] 1> and 1> [ 1> _Ty=int, 1> _Alloc=std::allocator<int> 1> ] 1> g:\_proggen\_workspaces\c++\visual studio 2010\projects\logfile\gameengine\bchelperfunctions.hpp(11): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "std::vector<_Ty>". 1> with 1> [ 1> _Ty=int 1> ] 1> Code wird generiert...ganz am ende bekomme ich aber diese meldung:
========== Erstellen: 1 erfolgreich, Fehler bei 0, 0 aktuell, 0 übersprungen ==========
soll ich das jetzt ignorieren?
was muss ich machen um diese warnungen loszuwerden?(ich will sie nicht einfach unterdrücken)
-
Meinst du nicht, das die MSDN Hilfe nicht auch schlau genug ist?

-
also ja.
ich denke dann mal das trifft auch auf ofsteams zu