Hi,
I have declared an exten struct 'linked_list' in a header file, this header file is included in the c file, and the necessary elements from the h file are declared. but when I try to access the members of an instance of the struct from the h file, there are errors stating that the struct has no member of that name
the code is as follows
h file:
Code:
typedef struct linked_list {
thread_t thread;
linked_list *next;
int isNull;
}linked_list;
extern linked_list *threads_head;
extern linked_list *threads_tail;
int totalSize = 0;
int hasHead = 0;
and some of the code for the c file (not all included,as same error thrown throughout the file):
Code:
#include <stdio.h>
#include "context.h"
#include "sched.h"
#include "thread.h"
#include <stdlib.h>
thread_t newThread;
linked_list threads;
linked_list *threads_head;
linked_list *threads_tail;
int totalSize;
context_t context_1;
context_t context_2;
void remove_thread(){
int pos;
pos = newThread.ID;
linked_list x, temp;
temp = *threads_head;
for(int i=0;i<totalSize;i++)
{
if(i==pos){
x=*temp.next;
temp.next=*temp.next.next;
free(&x);
}
temp=*temp.next;
}
}
void add_thread(thread_t* newThread){
if (totalSize==0){
threads_head->thread = &newThread;
threads_head->next = &threads_tail;
threads_head->isNull = 1;
totalSize++;
} else{
//threads_tail->next = *newThread;
linked_list newNullElement;
newNullElement.isNull =0;
linked_list newElement;
newElement.thread = newThread;
newElement.next = newNullElement;
newElement.isNull = 1;
threads_tail->next = newElement; //thread tail = new linked list
totalSize++;
threads_tail = &newElement;
}
}
Im probably making a silly little mistake, but I cant for the life of me figure it out!
I'd be super grateful for any help
Fiona