Dereferencing Pointer/Incompatible Pointer Type

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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 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

Not enough information.

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.
The line numbers are referencing line 14, and then 19-22.

Last edited on
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.

Can you post your full code?
I figured it out! I had Dlink, instead of DLink! Thanks for looking at it though!
Topic archived. No new replies allowed.