This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

simulation doesn't work

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.

Parents
  • It works fine for me using the Eval version of uVision v2.07 and C51 v6.03.

    What versions are you using?
    Does the message say anything other than just, "error 10?"

    Note that there is a bug in uVision2: the debug command line is supposed to be case-insensitive, which seems to be true for everything except structure member names!
    eg, buf.both and BUF.both both work, but buf.BOTH and BUF.BOTH both give:

    *** error 54: undefined struct/union member

    BTW: when posting code, it's much easier to read if you enclose it within &ltpre&gt and &lt/pre&gt tags - see the Tips for Posting Messages link in the sidebar.
    thus:
    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;
    }

Reply
  • It works fine for me using the Eval version of uVision v2.07 and C51 v6.03.

    What versions are you using?
    Does the message say anything other than just, "error 10?"

    Note that there is a bug in uVision2: the debug command line is supposed to be case-insensitive, which seems to be true for everything except structure member names!
    eg, buf.both and BUF.both both work, but buf.BOTH and BUF.BOTH both give:

    *** error 54: undefined struct/union member

    BTW: when posting code, it's much easier to read if you enclose it within &ltpre&gt and &lt/pre&gt tags - see the Tips for Posting Messages link in the sidebar.
    thus:
    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;
    }

Children