typedef struct secinfo_t {
struct secinfo_t* next; /* NULL for no next section */
const char* name; /* nul-terminated section name */
void* addr; /* Address of section in memory */
uint32_t size; /* length of section (bytes) */
uint32_t flags; /* flags, see below */
struct secinfo_t* romcopyof; /* this section is a ROM copy of 'romcopyof' */enter code here
/* Future fields go here */
} *secinfo_ptr;
什么是" next
"和" romcopyof
"在结构上使用类型指针创建的成员?我不明白的问题是我所创建的成员的结构类型是什么?有人可以更详细地解释一下吗?
答案 0 :(得分:0)
typedef struct secinfo_t {
struct secinfo_t* next; /* NULL for no next section */
const char* name; /* nul-terminated section name */
void* addr; /* Address of section in memory */
uint32_t size; /* length of section (bytes) */
uint32_t flags; /* flags, see below */
struct secinfo_t* romcopyof; /* this section is a ROM copy of 'romcopyof' */enter code here
} *secinfo_ptr;
结构中的struct secinfo_t* next;
是结构自身的引用,当结构对象与其他'实例'相关联时使用本身,即这通常用于(二进制)树或链接列表中的节点:
typedef struct Node Node;
struct Node
{
int value;
Node *next;
Node *prev;
};
来源:How to define a typedef struct containing pointers to itself?
有关如何使用此编码结构的示例,请参阅http://www.learn-c.org/en/Linked_lists和https://www.geeksforgeeks.org/binary-tree-set-1-introduction/
struct secinfo_t* romcopyof;
是指向secinfo_t
的ROM副本的指针,ROM是在EEPROM中或硬盘上而不是在执行代码的RAM中...