If your DLL and Exe use the static CRT, this won't work properly. Use the DLL CRT in both Exe and DLL. (/MD or /MDd)
| Unjedai wrote:
Can I have the following method in a DLL and call it from a Client, like this?
// DLL file
void DllFunction (std::vector<int> &B)
// Client file
void SomeFunction ()
When I try to do this I get a runtime error in _CrtIsValidHeapPointer (dbgheap.c) when SomeFunction returns. I figured the problem is that the DLL allocates the memory and the Client is trying to free it and that's bad.
So, what do people do when they want to pass an STL vector as a reference parameter to a DLL? Cannot such a basic thing be done?
I've made sure my runtime libraries are the same for the dll and the client (/MTd).
项目属性->c/c++->code generation->runtime library 改为MDd;
项目属性->general->use of mfc->use mfc in a shared dll