I'm rather new to c, and I'm trying to implement a linked list. I wrote this:
struct List;
typedef struct List* ListRef;
struct List{
void *data;
ListRef next;
ListRef last;
};
ListRef newList(void* headData);
[...]
ListRef append(ListRef list, void* data){
ListRef newlist = newList(data)
list->last->next = newList; //here I get a warning
list->last = newList; //here I get a warning
return newList;
}
newList is compiled with no warnings. In the two lines with the comments I get:
warning: assignment from incompatible pointer type
What am I doing wrong?
Thank you!
newList(data).newListthan the same name as the functionnewList(). Unless you're purposely trying to obfuscate code, it is a recipe for errors.