I understand why I have C4251 warning when I compile my codes as explained in here. My question is if the accessible export class members are from STL, could we ignore C4251 warning? I give a simple example to illustrate my question:
dll.h
#include <iostream>
#include <string>
using namespace std;
class __declspec(dllexport) HelloWorld
{
public:
string name;
HelloWorld();
HelloWorld(const string &str);
};
dll.cpp
#include "dll.h"
HelloWorld::HelloWorld()
{
name ="";
}
HelloWorld::HelloWorld(const string &str)
{
name = str;
}
The warning information I have obtained is as followings:
Warning 1 warning C4251: 'HelloWorld::name' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'HelloWorld' *\dll.h 9
My question is: can I ignore this warning? The way how I use this library is also very simple:
#include "dll.h"
#include <iostream>
using namespace std;
int main(void)
{
HelloWorld myworld;
myworld.name = "Tom's world";
cout<<myworld.name<<endl;
return 0;
}