I have a exe built by vs2012, which can successfully run with linking to dll built by vs2012, while the following error appeared when linking to the same dll built by vc6.
(Expression:_CrtIsValidHeapPointer(pUserData))
the only difference between the dll projects of vc6 and vs2012 is that the vc6 one fail to #include "SDKDDKVer.h"
Here is the code for export function of the dll
extern "C" _declspec(dllexport) RobotAI_Interface* Export()
{
return (RobotAI_Interface*)new RobotAI();
}
extern "C" _declspec(dllexport) void FreeRobotAIPointer(RobotAI_Interface* p)
{
delete p;
}
The program breaks at this specific point when debuging (a system code):
extern "C" _CRTIMP int __cdecl _CrtIsValidHeapPointer(const void * pUserData)
{
if (!pUserData)
return FALSE;
if (!_CrtIsValidPointer(pHdr(pUserData), sizeof(_CrtMemBlockHeader), FALSE))
return FALSE;
return HeapValidate( _crtheap, 0, pHdr(pUserData) );
->}
The arrow is where it breaks.
The following is my code where it breaks:
void CArmorClientDlg::AddToList(CString file_path_name)
{
pAIManager->Add(file_path_name);
string dll_name=pAIManager->GetAI_RobotName(pAIManager->GetAINum()-1);
CListBox* pList=static_cast<CListBox*>(GetDlgItem(IDC_LIST_AI));
pList->AddString((CString)dll_name.c_str());
->}
The arrow is where it breaks. All the operations related to dll are done in "Add(file_path_name)"
I know little about the dll things... How to solve the problem?
Thank you!
TIP: the reason that I have to support vc6 dll is that the project is an AI competition, dll is the AI program that built by different contastents. The majority of the students in my school may only use vc6.