There are two types of structures

typedef struct edict_s { ... entvars_t v; } edict_t; typedef struct entvars_s { ... edict_t *u; } entvars_t; 

When compiling, of course, it swears that the structure entvars_t is undeclared, how to let the compiler know that it will be further declared in the code?
Tried so typedef struct entvars_s entvars_t; but did not help.

    2 answers 2

    And if so?

     //struct edict_s; // Как правильно подсказывает @Abyx, даже это не нужно typedef struct entvars_s { ... struct edict_s *u; } entvars_t; typedef struct edict_s { ... entvars_t v; } edict_t; 
    • one
      struct edict_s; don't need to be here - Abyx
    • @Abyx: Right, forgot. - VladD
    • Thank you, it works that way - Vitaly Karpenko
    • @ Vitali: Please! - VladD

    I usually declare structures and their types at the top of header files, like this:

     struct element; struct list; typedef struct element *Element; typedef struct list *List; 

    And the structures themselves are described where I deem it logically necessary.

     struct list { Element Head, Tail; }; struct element { List Home; Element Next; int Value; }; 

    In my opinion, so very convenient.