Passing CString between DLLs
-
I have a DLL created in Visual Studio 2005, and going to use it in Visual Studio 2008. The function in the DLL takes CString as a parameter. Is it safe to send CString from VS08 to VS05/VC6 DLL? I think different versions of VC++ will have different internal implementation of CString and it would not be safe. Whats the best way?
-
I have a DLL created in Visual Studio 2005, and going to use it in Visual Studio 2008. The function in the DLL takes CString as a parameter. Is it safe to send CString from VS08 to VS05/VC6 DLL? I think different versions of VC++ will have different internal implementation of CString and it would not be safe. Whats the best way?
The VS2005 and VS2008 sides are going to use different CRT libraries so passing anything but const pointers isn't going to be safe. Also, as you mentioned, the CString implementations may be different so passing CStrings isn't safe. Passing LPCSTRs is safest - let the receiver make a local CString copy from the passed pointer if necessary. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
The VS2005 and VS2008 sides are going to use different CRT libraries so passing anything but const pointers isn't going to be safe. Also, as you mentioned, the CString implementations may be different so passing CStrings isn't safe. Passing LPCSTRs is safest - let the receiver make a local CString copy from the passed pointer if necessary. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
What about sending it as a LPCSTR :)
Bram van Kampen
-
What about sending it as a LPCSTR :)
Bram van Kampen
-
uus831 wrote:
What about sending std::string?
Same as CStringT :)
Mark Salsbery Microsoft MVP - Visual C++ :java: