1
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;

What is "next" and "romcopyof" members that are created with type pointer on the struct? My problem which I don't understand is the type of struct for that members is the same I created? Could someone explain me more detailed?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

1 Answers1

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;

the struct secinfo_t* next; in the struct is a reference of the struct to itself, this is used when the struct object is associated to other 'instances' of itself, i.e. this is often used for nodes in (binary ) trees or linked lists :

typedef struct Node Node;

struct Node
{
  int value;
  Node *next;
  Node *prev;
};

source : How to define a typedef struct containing pointers to itself?

for examples how to use this coding structures see http://www.learn-c.org/en/Linked_lists and https://www.geeksforgeeks.org/binary-tree-set-1-introduction/

struct secinfo_t* romcopyof; is a pointer to a ROM copy of secinfo_t, ROM is i.e. in EEPROM or on hard disc not in RAM where the code is executed ...

ralf htp
  • 9,149
  • 4
  • 22
  • 34