Quote:
Originally Posted by uofi2012
Ok, so I am trying to make a doubly linked list of job nodes but I get:
FileName.c:21: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â->â token
Code:
typedef struct _job{
int j_num;
int t;
int r_t;
int p;
struct _job *next;
struct _job *prev;
}job;
job *head; // ** line 21**
head->next = NULL;
job *curr;
What is the problem?
I also tried dynamically allocating space for the head ptr, but it says initializer element is not const. (this is strictly C btw)
Make sure you allocate the space first (I agree it shouldn't mater at compilation time though...) and then try these:
1) Try changing the variable and structure names and see if that helps (I've had odd name space clashes before that can cause BS compile errors like this...).
2) If that doesn't work then it's most likely something to do with the typedef-struct declaration. Try replacing the "struct _job *next;" with "void* next;" and see if that works (casting it if necessary).
Generally with stuff like this the best thing to do is just keep cutting away everything until you have the most basic example that doesn't compile (or run) as you expect and then look deeper at the code that is left to see what's going wrong.
I'm gonna crash out now, but if you don't fix your problem then post back and I'll see it tomorrow.
Juk