Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - HashKey() in XTPMacros.h causes problems
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HashKey() in XTPMacros.h causes problems

 Post Reply Post Reply
Author
Message
scotia View Drop Down
Newbie
Newbie


Joined: 26 February 2013
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote scotia Quote  Post ReplyReply Direct Link To This Post Topic: HashKey() in XTPMacros.h causes problems
    Posted: 02 May 2013 at 12:00am
HashKey() in XTPMacros.h may override MFC's HashKey() but it generates hash value in a different way from MFC. That means you cannot pass a CMap created in a DLL linked with ToolKitPro to the other DLL not linked with ToolKitPro. I don't know why we need the HashKey() in XTPMacros.h while there is one in MFC. Please remove the HashKey() in XTPMacros.h.

In XTPMacros.h:
template<> AFX_INLINE UINT AFXAPI HashKey<UINT_PTR>(UINT_PTR key) {
return (DWORD)(((DWORD_PTR)key)>>4);
}

In MFC:
AFX_INLINE UINT AFXAPI HashKey(ARG_KEY key)
{
// (algorithm copied from STL hash in xfunctional)
ldiv_t HashVal = ldiv((long)(ARG_KEY)key, 127773);
HashVal.rem = 16807 * HashVal.rem - 2836 * HashVal.quot;
if (HashVal.rem < 0)
HashVal.rem += 2147483647;
return ((UINT)HashVal.rem);
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.