Using SDCC compiler for a C51 simple application,
for the following two lines variable declarations:
unsigned int address;
unsigned char * mem_ptr;
I've got the compilation error "127" for the following instruction line:
mem_ptr = (unsigned char * )address;
The error "127" maps to:
"non-pointer type cast to generic pointer from type 'unsigned-int to type unsigned-char generic*"
NOW THE QUESTION: is there anybody of you who can kindly suggest me an alternative and compilable way to initialize the "mem_ptr" pointer variable with the content of the "address" one?
Thank you in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
or (untested) declare mem_ptr as a pointer to one of these spaces, like
1. __data unsigned char *mem_ptr;
2. __xdata unsigned char *mem_ptr;
3. __code unsigned char *mem_ptr;
4. ...
Otherwise SDCC would have to guess the memory space and its according TAG (most significant bits ot the generic pointer's value).
HTH,
Raphael
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using SDCC compiler for a C51 simple application,
for the following two lines variable declarations:
unsigned int address;
unsigned char * mem_ptr;
I've got the compilation error "127" for the following instruction line:
mem_ptr = (unsigned char * )address;
The error "127" maps to:
"non-pointer type cast to generic pointer from type 'unsigned-int to type unsigned-char generic*"
NOW THE QUESTION: is there anybody of you who can kindly suggest me an alternative and compilable way to initialize the "mem_ptr" pointer variable with the content of the "address" one?
Thank you in advance!
In which memory space is the object pointed to by address in?
Use
1. mem_ptr = (__data unsigned char *) address;
2. mem_ptr = (__xdata unsigned char *) address;
3. mem_ptr = (__code unsigned char *) address;
4. ...
or (untested) declare mem_ptr as a pointer to one of these spaces, like
1. __data unsigned char *mem_ptr;
2. __xdata unsigned char *mem_ptr;
3. __code unsigned char *mem_ptr;
4. ...
Otherwise SDCC would have to guess the memory space and its according TAG (most significant bits ot the generic pointer's value).
HTH,
Raphael