2 things, named the structure after struct keyword and before the {,
secondly
crossworks does not support anonymous unions that is a C++ feature..
do a bit of searching, there are several examples on how to bit adress ports
including one I posted a month or 2 ago..
--- bits_2_byte wrote:
> I switched from IAR to Crossworks and I'm trying
to get my code to
> compile. My first issue is with the below code
>
> volatile union
> {
> unsigned const char P2IN; /* Port 2 Input */
> struct
> {
> unsigned const int P2IN_0 : 1;
> unsigned const int P2IN_1 : 1;
> unsigned const int P2IN_2 : 1;
> unsigned const int P2IN_3 : 1;
> unsigned const int P2IN_4 : 1;
> unsigned const int P2IN_5 : 1;
> unsigned const int P2IN_6 : 1;
> unsigned const int P2IN_7 : 1;
> } P2IN_bit;
> } @ 0x0028;
>
> #define Sw1 P2IN_bit.P2IN_0
> #define Sw2 P2IN_bit.P2IN_1
> #define Sw3 P2IN_bit.P2IN_2
> #define P2_IN_3 P2IN_bit.P2IN_3
> #define P2_IN_4 P2IN_bit.P2IN_4
> #define P2_IN_5 P2IN_bit.P2IN_5
> #define P2_IN_6 P2IN_bit.P2IN_6
> #define P2_IN_7 P2IN_bit.P2IN_7
> Crossworks is giving me the following errors:
> empty declaration
> found '...', expecting ';'
> unrecognised declaration
>
> Am I missing a syntax issue or can I not define my port bits in this
> manner?
>
> Thank you for any help in advance!
>