0

The structure I want is a linked-list. Each block contains a header and a block_part. The header contains free, prev, and next. I'm just wondering if the code below is a valid implementation.

typedef struct block
{
    /*header + block*/
    bool free;
    block *prev;
    block *next;
    char block_part[];
} block;

In response to the comments, so the correct way to do this is :

typedef struct block block;

struct block
{
    /*header + block*/
    bool free;
    block *prev;
    block *next;
    char block_part[];
} ;

?

nalzok
  • 14,965
  • 21
  • 72
  • 139
Jobs
  • 3,317
  • 6
  • 26
  • 52

1 Answers1

0

Forward declare first ie

typedef struct block block;

then declare the struct ie

struct block {
  bool free;
  block * prev;
  block * next;
  char block_part[];
};
Harry
  • 11,298
  • 1
  • 29
  • 43