0

In the head file queue.h of BSD system, there is the following macro

#define TAILQ_ENTRY(type, qual)\
struct {\
    qual type *tqe_next;        /* next element */\
    qual type *qual *tqe_prev;  /* address of previous next element */\
}

With above definition, one is supposed to use it like

struct foo {
    TAILQ_ENTRY(struct foo, ) my_list;
    //some data here
};

My question is: what is the purpose of macro argument "qual" here, it seems does not play any part in code generated.

John Z. Li
  • 1,893
  • 2
  • 12
  • 19

1 Answers1

5

Well, in your usage, maybe it is unused, but one call can be made like

struct foo {
TAILQ_ENTRY(struct foo, ) my_list;
TAILQ_ENTRY(struct foo, const) my_list_too;
//some data here
};

where const is the type-qualifier.

The type qualifier can be either of const, restrict, volatile or _Atomic.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261