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

Code import help please

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;

Parents
  • This should do the trick:

    typedef struct  {
      char apiId;
      union  {
        char 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;
      } __attribute((packed)) variants;
      char crc;
      char *dataPtr;
      int rxState;
      int length;
      int index;
     } __attribute((packed)) XBPacket;
    

Reply
  • This should do the trick:

    typedef struct  {
      char apiId;
      union  {
        char 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;
      } __attribute((packed)) variants;
      char crc;
      char *dataPtr;
      int rxState;
      int length;
      int index;
     } __attribute((packed)) XBPacket;
    

Children
No data