Hi, I'm actually writing in C, but didn't know of another forum, as I used this one previously for C++. So I hope someone can still help. I have the following function and am receiving the following errors. If you could look over it and help me out that would be great!
void _addLinkAfter(struct cirListDeque *q, struct DLink *lnk, TYPE v) {
//make sure q is not null
assert(q!=NULL);
//make sure lnk is not null
assert(lnk!=NULL);
//check if lnk in deque
assert(lnk->next!=0);
assert(lnk->prev!=0);
//create new link
struct Dlink* temp;
temp = _createLink(v);
assert(temp!=0);
//add new link with value v after lnk
temp->next=lnk->next;
temp->prev=lnk;
lnk->next->prev=temp;
lnk->next=temp;
//increase by 1
q->size++;
}
And I receive the following errors:
cirListDeque.c: In function â_addLinkAfterâ:
cirListDeque.c:112: warning: assignment from incompatible pointer type
cirListDeque.c:117: error: dereferencing pointer to incomplete type
cirListDeque.c:118: error: dereferencing pointer to incomplete type
cirListDeque.c:119: warning: assignment from incompatible pointer type
cirListDeque.c:120: warning: assignment from incompatible pointer type
We don't know what cirListDeque, DLink or TYPE look like.
What does the declaration for _createLink look like?
Can't relate line numbers in error messages to line numbers in posted code.
"dereferencing pointer to incomplete type" implies you haven't declared that type.
That all looks pretty straight forward. Nothing jumps out at me other than the assumption that the definition of TYPE precedes the declaration of DLink and the declaration of DLink precedes the declaration of cirListDeque. You posted them in the reverse order and that would be a problem.