Print Page | Close Window

HashKey() in XTPMacros.h causes problems

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=21619
Printed Date: 18 June 2025 at 4:07am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: HashKey() in XTPMacros.h causes problems
Posted By: scotia
Subject: HashKey() in XTPMacros.h causes problems
Date 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);
}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net