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

how cain pass through a pointer's address to a function

I declared different parameters, variables and pointers and I put into in two blocks. I declare and defined function for calculating, saving and checking chksum for both block.
I realised that the compiler give error message when I try to pass through the pointer's address to a function. I tried to use an another pointer to point to the pointer's address but the compiler didn't support it. Has anybody a good idea to solve my problem.
thank in advace
leslie



#include <reg51.h>
#define record 7
#define byte unsigned char
#define word unsigned int
#define dword unsigned long int
//declare funtions
void save_block(byte xdata *start_addr,word xdata *chksum);
word calc_block(byte xdata *start_addr,word xdata *chksum);
bit chk_block(byte xdata *start_addr,word xdata *chksum);
//declare variables
xdata byte par_buff1[14];
xdata word chksum1;
//
xdata byte dummy1;
//
xdata byte xdata *rec_buf_start;
xdata byte xdata *rec_buf_end;
xdata byte xdata *wr_ptr;
xdata byte xdata *rd_ptr;
xdata word chksum2;
//
xdata word xdata **valami;

main()
{
//valami=&rec_buf_start;
if(chk_block&rec_buf_start,&chksum2))
{
// do something
}
if (chk_block(&par_buff1[0],&chksum1))
{
//do something
}
else
{
//do something
}
for(;;)
{
//do something
}
}
//
// functions definition
//
bit chk_block(byte xdata *start_addr,word xdata *chksum)
{
if(*chksum!=calc_block(start_addr,chksum))
{
return 1; //setb c
}
else
{
return 0;
}
}
word calc_block(byte xdata *start_addr,word xdata *chksum)
{
xdata word blsumma;
while(start_addr!=(byte *)chksum)
{
blsumma+=(byte)*start_addr++;
}
return blsumma;
}
void save_block(byte xdata *start_addr,word xdata *chksum)
{
*chksum=calc_block(start_addr,chksum);
}