关于结构体嵌套的问题

2019-03-25 20:28发布

我编写了下面住的那结构体,就是在一个结构体中嵌套一个结构体数组;程序如下:
typedef struct         
{
struct data TXBUF[CAN_TXBUF_LENGTH];
  volatile    uint32_t head;                /*!< ReceiveData Tx ring buffer head index */
  volatile    uint32_t tail;                /*!< ReceiveData Tx ring buffer tail index */
  volatile  uint32_t number;
}CAN_TXBUF;

typedef struct       
{
        uint32_t Frame;
        uint32_t MsgID;       
        uint32_t DataA;       
        uint32_t DataB;
        };
        struct data TXBUF[CAN_TXBUF_LENGTH];
哪位高手能指出哪里错了??谢谢 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
2条回答
zhaojun_xf
2019-03-26 03:22
_NXP LPC1000_
  1. #define CAN_TXBUF_LENGTH 10

  2. typedef struct
  3. {
  4. uint32_t Frame;
  5. uint32_t MsgID;
  6. uint32_t DataA;
  7. uint32_t DataB;
  8. } TXBUF;

  9. typedef struct
  10. {
  11. TXBUF txBuf[CAN_TXBUF_LENGTH];
  12. volatile uint32_t head; /*!< ReceiveData Tx ring buffer head index */
  13. volatile uint32_t tail; /*!< ReceiveData Tx ring buffer tail index */
  14. volatile uint32_t number;
  15. } CAN_TXBUF;
复制代码

这样是可以的:

[ 本帖最后由 zhaojun_xf 于 2012-7-26 11:46 编辑 ]

一周热门 更多>