std string/wstring and DLL
-
The standard C++ provides string/wstring, an instantiation of basic_string<>. However, the Windows versions in VC++ does not seems to cooperate with DLLs when exporting classes containing string/wstring members. VC++ keeps giving the warning C4251. Is there anyway to use the standard strings in DLL as class members of exported classes? Currently, I am being forced to use them as function arguments/parameters and it is not always good for most design. Regards, Paul.
-
The standard C++ provides string/wstring, an instantiation of basic_string<>. However, the Windows versions in VC++ does not seems to cooperate with DLLs when exporting classes containing string/wstring members. VC++ keeps giving the warning C4251. Is there anyway to use the standard strings in DLL as class members of exported classes? Currently, I am being forced to use them as function arguments/parameters and it is not always good for most design. Regards, Paul.
-
First question: What is error C4251, can you post the message that is with it? Second... I've never tried to do what your doing (at least I don't think so), but in COM we have to use BSTR ... not strings .... don't know if that will help at all.
Hello, Thanks for the response. Well, I never said error C4251, it is a warning! From the docs it is like this Compiler Warning (level 1) C4251 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' The specified base class was not declared with the __declspec(dllexport) keyword. A base class or structure must be declared with the __declspec(dllexport) keyword if a function in a derived class is to be exported. I am not building a COM interface, a simple non-MFC DLL. Regards, Paul.