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.
"I can see no wrong use of the pointers."
You're code is wrong.
The best method of removing the error is to correct the incorrect code!
No, it's not actually wrong - it's just suspect - which is why it only gets a warning, not an error.
"The best method of removing the error is to correct the incorrect code!"
There isn't an error to remove - but, as has already been explained, the suspicion could be removed by using an explicit cast!
Ok, I'll go along with the suspect.
That said, I always feel safer by treating warnings as an indication that the code/project needs modifying; if only to examine the suspect line and override the compiler's message.
In other words, I treat warnings as errors.
Anyway, the OP seems to have given up debating the point ... Maybe he's (finally) understood?
And the even better method is of course to learn how pointer indirection works. Then the Address field could be changed from uint to a pointer of the proper type - and no typecast would be needed.
Maybe he's (finally) understood?
I haven't seen any "Hey, thanks guys for explaining it to me." messages yet.
He may have just left to try his luck in a different forum.
Just noticed an update to the C51 compiler, bringing it up to 8.20.
Hope it reports the same warnings, else the OP will start all over again!?
More than 100 posts just because a broken assumption about how to use pointers...
About unsure/confused/insecure compilers. The developers of the compiler knows that some translation rules are less likely and that there may be a good idea to warn the user.
However, the compiler is most definitely without any feelings. And I'm pretty sure that the developers of the compiler are reasonably sure about what they do, and what they want their compiler to do.
It is all probabilities and experience. Compilers are normally designed (and the language it handles) by knowledgeable people. Knowledge normally implies experience. Experience tells that some constructs are seldom intended - such as the traditional if (a = b) ... - and it is then a good idea to add a warning. But the compiler is not unsure. And the compiler developers are not unsure. They are on the other hand suspecting that the end user is unsure - or just clueless...
Well, kinda flaming me for using the wrong terms (if millions of people think the same way, it's not necessarily correct, as the history shows) is actually not the help I hoped for. I actually found the only one solution that helped getting rid of this warning:
ptr_xdata = (uchar *) stPtr_Obj->Adresse;
The cast is the solution. It was hidden amongst the many text that was written telling me what to DO NOT, instead of telling me what to DO.
Thanks anyway, guys. I know you only did your best and I also know that you are so much into programming (and perhaps doing nothing else in your job) that you are unable to even consider a different terminology for the same understanding (I always knew what pointers are, I just call it differently). I guess the biggest problem with this compiler warning was the little word "conversion". Because when it says "conversion: non-pointer to pointer" for the line of code above, then it's clear for me that ptr_xdata is meant. And this pointer is not converted, it's indirectly set to a variable. So the whole confusion just started by a silly english warning...
No, you have never been flamed for using the wrong terminology.
It is a border case that you have been flamed: But for completely refusing to accept that your terminology is incorrect.
if millions of people think the same way, it's not necessarily correct, as the history shows
Not applicable, since we are not talking about what millions of people think, but what a few number of people have defined.
No, the cast was not hidden away somewhere. It has been discussed a number of times in a number of posts, but you have totally failed to understand our posts, since you have been using a home-grown vocabulary.
We have also discussed - multiple times - why the cast would not be needed at all, i.e. why the Adresse field shouldn't have been an integer but a pointer in the first place.
1000ml of water is the same as 1 litre of water. Still, you do a conversion of units when switching between the two. In the same way, the compiler has to do a conversion of data types (and in some cases a conversion of the binary representation).
"The cast is the solution. It was hidden amongst the many text that was written telling me what to DO NOT, instead of telling me what to DO."
No, it was not in the least bit hidden - I stated it very clearly and explicitly in the very first reply in this thread - 5-Feb-2008 06:36:
"As usual, an explicit cast should both stop the warning and make your intention clear"
Nothing hidden there at all!
View all questions in Keil forum