struct 初始化

看到某个源码,有个关于struct初始化的问题不是太清楚。

源码如下

 

#define _OBJ_CONTAINER_LIST_INIT(c)     \
{&(rt_object_container[c].object_list), &(rt_object_container[c].object_list)}
struct rt_object_information rt_object_container[RT_Object_Class_Unknown] =
{
/* initialize object container - thread */
{RT_Object_Class_Thread, _OBJ_CONTAINER_LIST_INIT(RT_Object_Class_Thread), sizeof(struct rt_thread)},
……
}

主要集中在宏 _OBJ_CONTAINER_LIST_INIT(c)上。

struct rt_object_information的定义如下

struct rt_object_information
{
enum rt_object_class_type type; /**< object class type */
rt_list_t object_list; /**< object list */
rt_size_t object_size; /**< object size */
};

rt_list_t 是个双链表指针

struct rt_list_node
{
struct rt_list_node *next; /* point to next node. */
struct rt_list_node *prev; /* point to prev node. */
};
typedef struct rt_list_node rt_list_t; /* Type for lists. */

怎么在宏中出现了两个 &rt_object_container[c].object_list ?



转载于:https://www.cnblogs.com/westfly/archive/2012/03/15/2398400.html

你可能感兴趣的:(数据结构与算法)