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>
]
この問題の解決策を教えてください。