This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

about error C212 in keilC51

hi: when I compile the below code ,the keil51 emergered a error : error C212: indirect call: parameters do not fit within registers .

source code:

typedef struct NODE{

struct NODE *link; int value;

}NODE;

int
compare_ints(void const *a,void const *b)
{ if(*(int *)a == *(int *)b) return 0; else return 1;

}

NODE *
search_list(NODE *node,void const *value, int(*compare)(void const *,void const *))
{

while(node != NULL ){

if(compare(&node->value,value)==0)//error point break;

node = node -> link;

}

return node;

}

int main()
{ NODE *cur,*root;
int value;

cur = search_list(root,&value,compare_ints);
}

I can find where the error happen ,I mark with"error point" in the code. the compare() function pointer can not be filled in parameters,or the compile gives an alarm. I don't know why.

Parents
  • Keil C51 has major issues with using function pointers:

    http://www.keil.com/appnotes/docs/apnt_129.asp

    www.keil.com/.../search.asp

    Basically, the 8051 is not "just another processor" that you can program as you would a PC, etc.

    The 8051 architecture has some very specific optimisations that make it very good for some things, and very poor for others - and function pointer is one of those things to which it is not well suited!

    If function pointers really are essential to your application, then you should probably not be using an 8051 - at the very least, you need to study the issues very carefully!

Reply
  • Keil C51 has major issues with using function pointers:

    http://www.keil.com/appnotes/docs/apnt_129.asp

    www.keil.com/.../search.asp

    Basically, the 8051 is not "just another processor" that you can program as you would a PC, etc.

    The 8051 architecture has some very specific optimisations that make it very good for some things, and very poor for others - and function pointer is one of those things to which it is not well suited!

    If function pointers really are essential to your application, then you should probably not be using an 8051 - at the very least, you need to study the issues very carefully!

Children
No data