我正在将我的 Visual Studio 2005 C++ 代码迁移到 Visual Studio 2010。不幸的是,我在 VS2010 上的 std::string 上遇到错误,而在 VS2005 中我以前从未遇到过此错误。
这是代码示例
#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>
]
请帮我解决这个问题。