I am having trouble resolving the issue in the following code:
typedef struct _symbol_key
{
// constructor
_symbol_key( const char *pszSym )
{
if ( pszSym )
strncpy( szSym, pszSym, sizeof(szSym));
else
szSym[0] = 0;
}
// overload the less than operator
bool operator < ( const _symbol_key &key ) const
{
int iRet = strcmp( szSym, key.szSym );
return (iRet < 0);
}
operator size_t() const
{
return hash_compare( szSym ); // error on this line...
}
unsigned long hash_compare(char *str) const
{
unsigned long hash = 5381;
int c;
while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}
char szSym[40];
} SYMBOL_KEY;
error C2664: 'mcapi::_symbol_key::hash_
compare' : cannot convert parameter 1 from 'const char [40]' to 'char *'
Start Free Trial