I have this code
if (hashtable_count(h) > 0)
{
do {
kk = (key*)hashtable_iterator_key(itr);
v =(value*) hashtable_iterator_value(itr);
....
key and value are both declared in the same code block as
struct key *k, *kk;
struct value *v;
and VC 2010 reports the following error
error C2065: ‘key’ : undeclared identifier
error C2059: syntax error : ‘)’
error C2065: ‘value’ : undeclared identifier
error C2059: syntax error : ‘)’
the errors are for the two assignment lines. Two first errors are for the first assignment statement and the next for the last one.
I will be happy to give more details if neccessary.
More information:
Here are the two functions
void * hashtable_iterator_key(struct hashtable_itr *i)
{ return i->e->k; }
void * hashtable_iterator_value(struct hashtable_itr *i)
{ return i->e->v; }
If I don’t type cast the returned value to key*, it reports type mismatch error
(key*) in you cast should be (struct key*)
You have not created the the type “key”.
i.e. you have not done:
Then (key*) would work.