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

Anonymous union inside a struct?

The C complier doesn't like this piece of source code:
-------------------------
struct MyUart {
union {
unsigned char rx; // read
unsigned char tx; // write
};
unsigned char control; // r/w
};

volatile struct MyUart far* const UART = 0x101010;

unsigned char ReadByte( void )
{
while ( (UART->control & 0x01) == 0 )
{}
return UART->rx;
}
--------------------
I get the following error:
UNION.C(15): error C70: rx: undefined member

However, I get no error at line #13 on the reference to UART->control. Is there something I'm overlooking?

0