ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Aug 10, 2006 6:00 am |
|
|
Strange, v3.187 and v3.236 of the compiler give me an error of 'Element is not a member', but version 3.249 compiles without error.
Thing is that I think the older compiler versions are correct and this is an error in v3.249.... maybe it depends on which C standard you are using, K&R or ANSII ?
The way I learned to program this was that you can not have unnamed structs within the union: Code: | typedef union
{
int8 _byte;
struct
{
int8 bit0:1;
int8 bit1:1;
int8 bit2:1;
int8 bit3:1;
int8 bit4:1;
int8 bit5:1;
int8 bit6:1;
int8 bit7:1;
} MyBits; // <--- Added a name for the struct
} RESPONSE_1;
void main(void) // Changed to void, returning a value has no use and is waste of program memory.
{
RESPONSE_1 response;
response.MyBits.bit0 = 0;
}
|
|
|