Zaid Amir
Zaid Amir

Reputation: 4785

CMap lookup failing

I have an MFC application. It has a CMap which contains certain data objects, the map is declared as CMap<DWORDLONG, DWORDLONG,_ItemsObj*,_ItemsObj*> where _ItemsObj is a structure that contains various data.

The problem I'm facing is that when I try to search for an entry the Lookup method fails unexpectedly on x64 builds (and ONLY on x64 builds).

Here's the code I'm using

BOOL IsItemExist(DWORDLONG dwid)
{_ItemsObj* pObj=NULL;
if(!m_Itemsmap.Lookup(dwid,pObj))
{return FALSE;}
return TRUE;
}

Now this works perfectly on a 32-bit build of my application. However on an x64 build the Lookup always fails even though the items are present in the map and the key I'm looking for is present in the map.

I think its somewhat related to a build configuration issue, I have checked the linking properties and build configuration for both the x86 and the x64 option for the app project and they use the exact same configuration except for the target machine option (which should be different).

Can someone please help me fix this, I've been looking all over the internet for a solution but could not find anything.

Oh and I'm using VS 2010 SP1

Regards

Upvotes: 1

Views: 1033

Answers (1)

dlb
dlb

Reputation: 983

There are five global helper functions that CMap, CList and CArray uses. They are CompareElements, CopyElements, DumpElements, HashKey and SerializeElements. Your problem is likely with SerializeElements which CMap uses to to store collection element. The other thing to try is to declare your CMap as CMap < DWORDLONG, DWORDLONG, _ItemsObj,_ItemsObj*>

Upvotes: 2

Related Questions