We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I just noticed that my Keil C compiler doesn't flag assignment of an unsigned char to a pointer as an error:
unsigned char xdata *src; unsigned char xdata array[10]; src = array[0];
src = &array[0];
"Is this some known bug?" Nope. What you have written is perfectly valid 'C' syntax - so the compiler has nothing to complain about. The fact that you can do this in 'C' is, of course, both a blessing and a curse: a blessing as the compiler won't get in your way if you have a valid reason to do it; and a curse if you do it by accident - like here! As I've said before, "big" compilers like UNIX native ones, MSVC, Borland, etc tend to give you far more in the way of diagnostics than the "small" embedded cross-compilers like Keil. Such "big" compilers may well give you a "suspicious pointer conversion" warning, or similar; but in the embedded world, it's more likely that you do want to do "dirty tricks" like this... Therefore, as I've also said before, it is worth writing your code in such a way that a "big" compiler will also accept it - and give you all those extra warnings (you can download the Borland Compiler for free). Alternatively, use a static-analysis tool like lint See http://www.keil.com/forum/docs/thread1680.asp