Reputation: 2987
I'm having some trouble with structs..
I have the following code:
typedef struct filaNo{
Range data;
struct filaNo* prox;
}tfilaNo;
typedef struct tfifo {
tfilaNo* inicio;
tfilaNo* final;
} tfifo;
And I want to include this list in another struct:
typedef struct
{
int threadId;
double threshold;
double areaCalc;
tfifo intervalos;
}ThreadData;
When I use only tfifo it works perfectly, but when I include into ThreadData I receive 55 errors (like: "syntax error: identifier 'tfifo'"...) and so many others like this... seems like the compiler is lost.
Does anyone know how to solve this?
Thank you very much!
EDIT: some more code :)
tfifo works fine alone, I can do something like this:
tfila doc;
Range range;
int a;
create_fifo(&doc);
range.p1.x = 0;
range.p2.x = 33;
range.p1.y = 0;
range.p2.y = 0;
range.area = 0;
insert_fifo (&doc, range);
while(!empty_fifo(doc)){
remove_fifo(&doc,&range);
printf(" %d\n", range.p2.x);
}
Now I want to include this into ThreadData, because I need a list for every ThreadData struct.
Error 2 error C2059: syntax error : '}'
Error 1 error C2061: syntax error : identifier 'tfila'
Error 18 error C2065: 'i' : undeclared identifier
But the compiler gets totally lost after this... giving me so many errors that doesn't exist...
Upvotes: 2
Views: 1259
Reputation: 10516
In C , you need Use like this
typedef struct struct_name
{
//...
}mytype_t;
Modify this
typedef struct give_some_name
{
int threadId;
double threshold;
double areaCalc;
tfifo intervalos;
}ThreadData;
EDIT
Here you are using same name modify this also
typedef struct tfifo_t {
tfilaNo* inicio;
tfilaNo* final;
} tfifo;
Upvotes: 0
Reputation: 157
Is this the real code or a typo?
typedef struct tfifo {
tfilaNo* inicio;
tfilaNo* final;
} tfifo;
You are using the same name for the struct and the typedef. Maybe this is the problem.
Upvotes: 1