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 I am new to C and am trying to convert some C code into the Keil dialect. Mostly successful, but have got really stuck on the following fragment. I get the error as shown. After hours of playing with variations I just can't work it out. Would some kind soul please assist - thanks!
typedef struct { uint8 apiId; union { uint8 payload[ 100 ]; XB_TX64 tx64; XB_TX16 tx16; XB_TXStatus txStatus; XB_RX64 rx64; XB_RX16 rx16; XB_ATCommand atCommand; XB_ATCommandResponse atResponse; XB_IO64 io64; XB_IO16 io16; }; /* "warning #40-D: expected an identifier" */ uint8 crc; uint8 *dataPtr; int rxState; int length; int index; } __attribute((packed)) XBPacket;
convert some C code into the Keil dialect.
Actually, no. You're trying to convert some other compiler's dialect back into something closer to standard C. The dialect issue at hand is an anonymous union member in a struct. Standard C doesn't allow that, but some compilers do.
This will be tedious to fix. You'll have to name the union element, and change each and every access to it to include the union's own name.
get the error as shown.
No. What you show is a warning, not an error.