Possible Duplicate:
std::vector needs to have dll-interface to be used by clients of class 'X<T> warning
This is my first post in this group.
I am creating a DLL and calling it in the main file of the application. The code compiles fine but I get the following error:
warning C4251: 'PNCBaseClass::m_vAvailChannelsFromRx' : class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'PNCBaseClass'
3> with
3> [
3> _Ty=int
3> ]
My code is as follows:
#define TEST_API __declspec(dllexport)
class TEST_API PNCBaseClass
{
public:
vector<int> m_vAvailChannelsFromRx
};
I have looked up for solutions and tried and failed.
I do not want to disable the warning.
Never keep STL containers as exported class members. Client application may be compiled with different STL version than yours, with undefined runtime behavior. In your case, it is easy to replace vector<int> member with pointer vector<int>*. Initialize it in the class constructor, and release in the class destructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With