I've been trying to figure this out for a while now, but cannot find a solution. I am building a linked list and when I try to pass the list as a pointer to anything I get an error: Dereferencing Pointer to incomplete type.
Here is my struct declaration
typedef struct listStruct{
char *name;
int size;
boolean inRestStatus;
list *next;
}list;
and one of the many functions that do not work.
void addToList(list *l, char * name, int size){
list *tmp;
while(l->next != NULL){
l = l->next;
}
tmp = malloc(sizeof(list));
tmp->name = name;
tmp->size = size;
tmp->inRestStatus = NO;
tmp->next = NULL;
l->next = tmp;
}
and the header
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct listStruct list;
I have tried changing the struct declaration to
typedef struct listStruct list{
...
};
and received the error: request for member in something not structure or union. If anyone has any ideas that'd be awesome.
Edit
The struct definition is/was in a main function in a seperate file than the function, I have since moved the definition to the header file.