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.
Hi all, I try to use the simulator with a code that contains struct or union, but it doesn't seem to see members. Here is an example code: struct chuf { unsigned char hi; unsigned char lo; }; union { struct chuf chi; unsigned int both; } buf; void main(void) { buf.chi.hi =5; buf.chi.lo =1; buf.both =0x1122; while (buf.both) buf.both>>=1; } When I try to see something like buf.both, it shows error 10. By the way, where can one see the list of simulator errors? When I look for just buf, it shows the first byte of this union. At the same time, within the memory it seems to work right. Can anything be done about it? Thanks, Michael.
"You don't call it a bug, I do." No, it's not a bug; it's a direct consequence of the way Keil have chosen to implement their support for inline assembler, as Jon has explained. You may consider this to be a bad implementation, but that's a different issue! BTW: Keil are not alone in choosing this implementation. BTW2: You see a similar effect if you #include executable code in a 'C' source file: the 'C' compiler only sees the resulting pre-processed file, so it can't generate line number debug information for the #included file! This is certainly not limited to just Keil.