打印
[C语言]

结构体嵌套问题

[复制链接]
1113|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
chenyu988|  楼主 | 2015-10-10 10:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
chenyu988|  楼主 | 2015-10-10 10:41 | 只看该作者
链表和数据结构要看看

使用特权

评论回复
板凳
chenyu988|  楼主 | 2015-10-10 10:43 | 只看该作者
typedef struct __AJ_SlippedBuffer {
    uint8_t* buffer;
    uint16_t allocatedLen;
    uint16_t actualLen;
    struct __AJ_SlippedBuffer volatile next;
} AJ_SlippedBuffer;

这个是否合法呢。

使用特权

评论回复
地板
ayb_ice| | 2015-10-10 11:53 | 只看该作者
chenyu988 发表于 2015-10-10 10:43
typedef struct __AJ_SlippedBuffer {
    uint8_t* buffer;
    uint16_t allocatedLen;

这外肯定不行的,这样子子孙孙无穷无尽

使用特权

评论回复
5
chenyu988|  楼主 | 2015-10-10 13:30 | 只看该作者
ayb_ice 发表于 2015-10-10 11:53
这外肯定不行的,这样子子孙孙无穷无尽

32位下:
AJ_SlippedBuffer volatile* bufferRxQueue;

typedef struct __AJ_SlippedBuffer {
    uint8_t* buffer;
    uint16_t allocatedLen;
    uint16_t actualLen;
    struct __AJ_SlippedBuffer volatile* next;
} AJ_SlippedBuffer;
对于struct __AJ_SlippedBuffer volatile* next;t是不是相当于只包含uint8_t* buffer;和uint16_t allocatedLen两个变量?

使用特权

评论回复
6
ayb_ice| | 2015-10-10 13:48 | 只看该作者
本帖最后由 ayb_ice 于 2015-10-10 13:50 编辑
chenyu988 发表于 2015-10-10 13:30
32位下:
AJ_SlippedBuffer volatile* bufferRxQueue;

这就是典型的链表结构,百度下就明白了
成员多包含了一个指针而已,指向与自己结构一样的结构体而已,

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

47

主题

1108

帖子

14

粉丝