title: Compilation error struct has no member named next and prev
body: <p>Hey am trying to implement a generic list iterator that can store elements of any type.It has other files to tackle positive integer types and string types.However,I am receiving an error stating that the struct IteratorGRep has no member named 'next' and also for 'prev'.The Node next and prev have both been declared already and this should be working fine but am not sure where the error is.I am using a linux environment and the errors are indicative at compile time.Here is the code:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;assert.h&gt;
  #include "iteratorG.h"
  
  typedef struct Node {
  
    char   *value;  // value of thee list item (string)
    struct Node *prev;
    // pointer previous node in list
    struct Node *next;
    // pointer to next node in list
  
    // implemented struct here .. 
  } Node;
  
  typedef struct IteratorGRep {
  
    int  numofit;      // count of items in list
    Node *head;      // first node in list
    Node *curr;       // current node in list
    Node *tail;       // last node in list
  
    ElmCompareFp  cmpElm;
    ElmNewFp  newElm;
    ElmFreeFp freeElm;
  
    // implemented struct here .. 
  
  } IteratorGRep;
  
  
  /*
  
  
    // functions below .... 
   */
  
  
  IteratorG newIterator(ElmCompareFp cmpFp, ElmNewFp newFp, ElmFreeFp freeFp){
  
      struct IteratorGRep *it;
  
    it = malloc(sizeof (struct IteratorGRep));
    assert (it != NULL);
    it-&gt;numofit = 0;
    it-&gt;head = NULL;
    it-&gt;tail = NULL;
    it-&gt;curr = NULL;
    it-&gt;cmpElm=cmpFp;
    it-&gt;newElm=newFp;
    it-&gt;freeElm=freeFp;
    return it;
  
      // created list 
  }
  
  int  add(IteratorG it, void *vp){
  
    Node *temp=NULL;
    temp=it-&gt;next;
    it-&gt;next=vp;
    vp-&gt;prev=it;
    vp-&gt;next=temp;
    temp-&gt;prev=vp;
  
      // Inserts element pointed by 'vp' into list iterator 'it' 
      return 1;
  }
  int  hasNext(IteratorG it){
  
    if(it-&gt;next!=NULL)
     {
       return 1;
     }
  
      // check for any next elements  
      return 0;
  }
  int  hasPrevious(IteratorG it){
  
      if(it-&gt;prev!=NULL)
      {
        return 1;
      }
      // check for any previous elements 
      return 0;
  }
  void *next(IteratorG it){
    if(it-&gt;next!=NULL)
    {
      it=it-&gt;next;
      Node *curre=it-&gt;curr;
      return curre;
  
    }
      // move to next element
      return NULL;
  }
  void *previous(IteratorG it){
  
      if(it-&gt;prev!=NULL)
      {
        it=it-&gt;prev;
        Node *curre=it-&gt;curr;
        return curre;
  
      }
  
      // moves to previous element
      return NULL;
  }
  int  del(IteratorG it){
    if(it-&gt;prev!=NULL)
    {
      Node *temp_curr=it-&gt;curr;
      Node *temp_prev=it-&gt;prev-&gt;prev;
      temp_curr-&gt;prev=temp_prev;
      temp_prev-&gt;next=temp_curr;
      return 1;
  
    }
       // removes previous element from list 
    if(it-&gt;prev==NULL)
    {
      return 0;
    }
  }
  int  set(IteratorG it, void *vp){
    if(it-&gt;prev!=NULL)
    {
  
    Node *store_curr=it-&gt;curr;
    Node *store_prev=it-&gt;prev-&gt;prev;
  
    store_curr-&gt;prev=vp;
    vp-&gt;next=store_curr;
    store_prev-&gt;next=vp;
    vp-&gt;prev=store_prev;
    return 1;
    }
      // Replaces previous element with the element (*vp) 
      return 0;
  }
  IteratorG advance(IteratorG it, int n){
  
  
      // Advance by n times and return list with n times of elements
      // To  implement function here and change return value 
      return NULL;
  }
  void reverse(IteratorG it){
    Node *curr = it-&gt;head;
    Node *temp = NULL;
    while(curr != NULL) {
      temp = curr-&gt;next;
      curr-&gt;next = curr-&gt;prev;
      curr-&gt;prev = temp;
      curr = temp;
    }
    temp = it-&gt;head;
    it-&gt;head = it-&gt;tail;
    it-&gt;tail = temp;    
  
      // reverses order of list  
  }
  IteratorG find(IteratorG it, int (*fp) (void *vp) ){
  
      // finds elements after current position,append to new list
      // To implement function here and change return value 
  
       return NULL;
  }
  
  int distanceFromStart(IteratorG it){
  
    Node *c=it-&gt;curr;
    int count=0;
  
    if (c-&gt;prev==NULL){
      return 0;  
    }
  
    while(c-&gt;prev!=NULL)
    {
      c=c-&gt;prev;
      count++;
      return count;
    }
  
  
       // counts number of nodes from current position to start of list 
  
  }
  int distanceToEnd(IteratorG it){
  
    Node *cu=it-&gt;curr;
    int count=0;
  
    if (cu-&gt;next==NULL){
      return 0;  
    }
    while(cu-&gt;next!=NULL)
    {
      cu=cu-&gt;next;
      count++;
      return count;
    }
      // counts number of nodes from current position to end of list  
  
  }
  void reset(IteratorG it){
  
    it-&gt;curr=it-&gt;head;
  
      // reset to start of list  
      return;
  }
  void freeIt(IteratorG it){
    assert(it != NULL);
    Node *curr, *prev;
    curr = it-&gt;first;
    while (curr != NULL) {
      prev = curr;
      curr = curr-&gt;next;
      free(prev-&gt;value);
      free(prev);
    }
    free(it); 
  
      // remove nodes in it and free memory  
  
  }
  </code></pre>
  
  <p>This is the header file for the code:</p>
  
  <pre><code>#ifndef LISTITERATORG_H
  #define LISTITERATORG_H
  
  #include &lt;stdio.h&gt;
  
  typedef struct IteratorGRep *IteratorG;
  
  typedef int   (*ElmCompareFp)(void const *e1, void const *e2);
  typedef void *(*ElmNewFp)(void const *e1);
  typedef void  (*ElmFreeFp)(void *e1);
  
  
  IteratorG newIterator(ElmCompareFp cmpFp, ElmNewFp newFp, ElmFreeFp freeFp);
  int  add(IteratorG it, void *vp);
  int  hasNext(IteratorG it);
  int  hasPrevious(IteratorG it);
  void *next(IteratorG it);
  void *previous(IteratorG it);
  int  del(IteratorG it);
  int  set(IteratorG it, void *vp);
  IteratorG advance(IteratorG it, int n);
  void reverse(IteratorG it);
  IteratorG find(IteratorG it, int (*fp) (void *vp) );
  int distanceFromStart(IteratorG it);
  int distanceToEnd(IteratorG it);
  void reset(IteratorG it);
  void freeIt(IteratorG it);
  
  #endif
  </code></pre>
  
  <p>One of the functions have yet to be implemented and are indicated in the code itself.But i guess that might not be the source of issue here.I perceive that the Node is not being utilised properly here.</p>