0
我正在将Visual Studio 2005 C++代码迁移到Visual Studio 2010.不幸的是,我在VS2010上遇到std :: string错误,而在VS2005中我从来没有发生过此错误。std :: string在Visual Studio 2010中给出了编译器警告
下面是代码示例
#include<string>
typedef std::string String
class __declspec(dllexport) SomeClass
{
public:
String somevariable; // compiler warning here. Please see below for the compiler warning.
void SomeFunction(String sName); // No compiler errors or warning here
};
编译器警告为:
error C2220: warning treated as error - no 'object' file generated
warning C4251: 'SomeClass::somevariable' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'SomeClass'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
请帮忙给我这个问题的解决方案。
http://stackoverflow.com/questions/5661738/common-practice-in-dealing-with-warning-c4251-class-needs-to-have-dll-inter – Arun 2013-03-25 03:35:27
使用PIMPL成语一种可能的解决方案是这里-http://stackoverflow.com/questions/767579/exporting-classes-containing-std-objects-vector-map-etc-from-a-dll – Arun 2013-03-25 03:40:07