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

Error in Two long variable Passing in Funciton to Pointer

Hi,
I am using Function to Pointer. i have definded this functin poiter in one structure with two long variable argument.
it is giving me error below.

Error C212: indirect call: parameters do not fit within registers.

though it is given in c51.pdf that it will pass funciton argument with two long variable, i face this error.

expecting solution as soon as possible

code is like this

typedef struct
{
unsigned long var1;
unsigned long var2;
void (*funptr) (unsigned long var1,unsigned long var2);

}test;

void main()
{

struct test *pt,t;

t.vars1 = 6550;
t.vars2 = 6551;
t.funptr = TESTING;
// where TESTING is fucntion definition macro

pt->funptr(pt->var1,pt->var2);
// here i get error listed above
}

thanks
niraj

Parents
  • Hi dear Dharmesh
    you solution is working nice for keil

    again one another solution i found is
    to pass structure pointer in that pointer to function.

    so that i can use my code for keil and another compiler also like VC++


    typedef struct
    {
    unsigned long aa;
    unsigned long bb;
    void (*funptr) (test *ts);

    }test;

    void TESTING(test *ts)
    {
    unsigned long var1,var2;
    unsigned long tmp;

    var1 = ts->aa;
    var2 = ts->bb;

    tmp=var1;
    var1=var2;
    var2=tmp;
    }

    void main()
    {

    test t;

    t.aa = 6550;
    t.bb = 6551;
    t.funptr = TESTING;

    t.funptr(&t);
    }

Reply
  • Hi dear Dharmesh
    you solution is working nice for keil

    again one another solution i found is
    to pass structure pointer in that pointer to function.

    so that i can use my code for keil and another compiler also like VC++


    typedef struct
    {
    unsigned long aa;
    unsigned long bb;
    void (*funptr) (test *ts);

    }test;

    void TESTING(test *ts)
    {
    unsigned long var1,var2;
    unsigned long tmp;

    var1 = ts->aa;
    var2 = ts->bb;

    tmp=var1;
    var1=var2;
    var2=tmp;
    }

    void main()
    {

    test t;

    t.aa = 6550;
    t.bb = 6551;
    t.funptr = TESTING;

    t.funptr(&t);
    }

Children
No data