I get a lot of "assignment from incompatible pointer type" warnings, and I don't know why. The warnings appear in this part:
void addNode(linkedList* list, int board)
{
Node* newNode = createNode(board);
(list->last)->next = newNode; // this line has warning
newNode->prev = list->last; // this line has warning
}
The structs and the rest of the code is:
typedef struct{
int board;
struct Node* next;
struct Node* prev;
}Node;
typedef struct{
int length;
Node* first;
Node* last;
}linkedList;
Node* createNode(int board)
{
Node* node = (Node*)malloc(sizeof(Node));
node->next = NULL;
node->prev = NULL;
node->board = board;
return node;
}
linkedList* createList()
{
linkedList* list = (linkedList*)malloc(sizeof(linkedList));
list->first = NULL;
list->last = NULL;
list->length = 0;
return list;
}
addNodefunctionlist->lastis dereferenced ((list->last)->next = newNode;) without checking if it's NULL (empty list).