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
  • 13,395
  • 18
  • 64
  • 118
Jobs
  • 3,087
  • 6
  • 22
  • 49

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
  • 10,932
  • 1
  • 25
  • 40