首页 新闻 会员 周边

链表指针初始化问题

0
[待解决问题]
  1. 将链表索引指针指向最后一个节点的操作为“pxList->pxIndex=(ListItem_t*)&(pxList->xListEnd)”,为什么该操作不是“pxList->pxIndex=pxList->xListEnd”?
  2. “(ListItem_t*)&(pxList->xListEnd)”的具体含义是什么?
问题补充:

补充使用到的两个结构体:
1.

typedef struct xLIST
{
    UBaseType_t uxNumberOfItems;
    ListItem_t * pxIndex;
    MiniListItem_t xListEnd;
}List_t;
struct xMINI_LIST_ITEM
{
    /* data */
    TickType_t xItemValue;
    struct xLIST_ITEM * pxNext;
    struct xLIST_ITEM * pxPrevious;
};
typedef struct xMINI_LIST_ITEM MiniListItem_t;
void vListInitialise(List_t * const pxList)
{
    pxList->pxIndex=(ListItem_t *) & (pxList->xListEnd);
}
短腿小兽的主页 短腿小兽 | 菜鸟二级 | 园豆:213
提问于:2020-04-29 17:13
< >
分享
所有回答(1)
0

xLIST结构体定义中,pxIndex是(ListItem_t )类型
第二个问题,(ListItem_t
)&(pxList->xListEnd)的目的是将&(pxList->xListEnd)强制转换为(ListItem_t)类型;
第一个问题,(pxList->xListEnd)和(pxList->pxIndex)的类型不一样,所以需要将类型转为pxList->pxIndex的类型,也就是(ListItem_t
)类型。

寻觅beyond | 园豆:923 (小虾三级) | 2020-04-29 17:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册