Hello!
I have uVision that compiles fine with the C51 v7.03 compiler and the related package, but not complete with the 8.06. I used two different Keil installations. All files are in the same folder.
In the 8.06 I get linker errors like "object does not fit in to pdata page" and "0080H". This looks like the compiler was thinking the PDATA was only 128 bytes, but it is set to 256 bytes in the startup.a51. Any clue what's different in the newer Keil package?
Also there is a warning in 8.06 (which does not show in 7.03) "converting non-pointer to pointer" on this
ptr_xdata = sPtr_obj->Adresse;
while the vars are set like this:
uchar uc_set_obj( uchar pdata *ptr_Set) { uchar i; uchar xdata *ptr_xdata; struct stOBJADR code *sPtr_obj; sPtr_obj=&Obj[*ptr_Set]; . . . ptr_xdata = sPtr_obj->Adresse; }
The struct stOBJADR has a member "uint Adresse;"
I can see no wrong use of the pointers. I just want to be sure that the warning does not affect the code to not work correctly.
As you say, ptr_xdata is a pointer, and sPtr_obj->Adresse isn't - so the warning is perfectly correct!
As usual, an explicit cast should both stop the warning and make your intention clear...
"I just want to be sure that the warning does not affect the code to not work correctly"
There is always a risk in playing fast-and-loose with pointers like this!
I think you should be OK with the XDATA-Specific pointer...
Hello Andy! Thanks for your help.
You are wrong. "sPtr_obj->Adresse" is a struct pointer and gives me a number, an address that "ptr_xdata" is set to.
You are wrong.
No, he's quite correct. The -> operator is the "member access from pointer" operator, which return the actual member, not a pointer to it.
Of course I meant, that stObj is the pointer to the struct and by accessing the member Adresse with -> it returns a value, because Adresse is uint. So the pointer ptr_xdata is set to this address. Still nothing wrong here. And, as I said, this compiles without warning at 7.03 and runs fine.
Darn, those typos! The struct pointer should be sPtr_obj in my above posting.
Of course I meant, that stObj is the pointer to the struct and by accessing the member Adresse with -> it returns a value, because Adresse is uint. So the pointer ptr_xdata is set to this address.
Well, you say it here: stObj->Adresse is a uint, and ptr_xdata is a pointer. The compiler will do the assignment, but issue a warning due to potentially incompatible data types. If you want the warning to go away, you need to cast the uint explicitly to a pointer.
Which falls back to Andy's perfectly correct comment: "As you say, ptr_xdata is a pointer, and sPtr_obj->Adresse isn't - so the warning is perfectly correct!"
Hmm, that'll do. But, incompatible data types? A pointer's address is always uint, so the compiler should not complain.
Thanks!
A pointer's address is always uint, so the compiler should not complain.
Maybe this is true for (today's) PC compilers, but it's definitely not true for the C51 compiler.
The C51 manual has a detailes explanation on how pointer work:
http://www.keil.com/support/man/docs/c51/c51_le_ptrs.htm
http://www.keil.com/support/man/docs/c51/c51_le_genptrs.htm
www.keil.com/.../c51_le_memspecificptrs.htm
Is it?!
A Generic Pointer in C51 is 3 bytes - so not a uint at all!
Anyhow, you're setting the pointer's value not its address!
Given that you haven't shown your definition of "uint", I s'pose you could have defined it such that this is true...
View all questions in Keil forum