I am trying to write a generic linked list in c, but for some reason i keep getting errors saying "incompatible pointer type. This is the code and erros:
OUTPUT from GCC
slist.h:25:2: error: unknown type name ‘slist_elem’
slist_elem *next;
^
slist.c: In function ‘destory’:
slist.c:33:8: warning: assignment from incompatible pointer type [enabled by default]
lptr = lptr->next;
^
slist.c: In function ‘insert’:
slist.c:51:20: warning: assignment from incompatible pointer type [enabled by default]
list->tail->next = element;
^
slist.c: In function ‘remove’:
slist.c:61:22: warning: initialization from incompatible pointer type [enabled by default]
slist_elem *lptr = list->head->next;
^
slist.c:70:20: warning: comparison of distinct pointer types lacks a cast [enabled by default]
while(lptr->next != list->tail) {
^
slist.c:71:26: error: request for member ‘data’ in something not a structure or unionif(!compare(lptr->next->data, elem->data)) {//found a match
^
slist.c:72:20: error: request for member ‘data’ in something not a structure or union
free(lptr->next->data);
^
slist.c:74:19: warning: comparison of distinct pointer types lacks a cast [enabled by default]
if(lptr->next != list->tail)
^
slist.c:75:29: error: request for member ‘next’ in something not a structure or union
lptr->next = lptr->next->next;
^
slist.c:79:10: warning: assignment from incompatible pointer type [enabled by default]
lptr = lptr->next;
^
slist.c: In function ‘list_size’:
slist.c:93:8: warning: assignment from incompatible pointer type [enabled by default]
lptr = lptr->next;
^