si lo so che in C si possono creare strutture dinamiche... era solo che non sapevo più dove andare a parare
quello che ho postato era solo un esempio ma già adesso non capisco una cosa:
se voglio creare una variabile (in altri linguaggi sarebbe un oggetto) per poter utilizzare sta benedetta lista come dovrei fare?
node *list;
oppure
_node *list;
???
cmq a sto punto posto il codice che mi interessa veramente:
codice:
// Tipo di dato che identifica il senso di marcia.
enum {
on_left,
on_right
} tGearWay;
// Tipo di dato che identifica le categorie di treni.
enum {
freight, // merci.
intercity,
regional
} tCategory;
// Tipo di dato che identifica il treno.
typedef struct {
WINDOW *win;
tCategory type;
tGearWay way;
pthread_cond_t gone;
pthread_cond_t arrived;
} tTrain;
// Tipo di dato che identifica il garage del controllore.
typedef struct tBox *tGarage;
typedef struct {
tTrain train;
tGarage next;
} tBox;
// Tipo di dato che identifica il controllore di una tratta ferroviaria.
typedef struct {
sem_t semaphore;
int trade;
tGarage garage;
} tController;
e mi dice:
error: parse error before "tCategory"
treni.c:46: warning: no semicolon at end of struct or union
treni.c:47: warning: data definition has no type or storage class
treni.c:50: error: parse error before '}' token
treni.c:50: warning: data definition has no type or storage class
treni.c:55: error: parse error before "tTrain"
treni.c:55: warning: no semicolon at end of struct or union
treni.c:57: error: parse error before '}' token
treni.c:57: warning: data definition has no type or storage class