title: C: dereferencing pointer to incomplete type singly linked list
body: <p><strong>list.h</strong></p>
  
  <pre><code>#ifndef LIST_H
  #define LIST_H
  
  /* Function prototypes */
  struct nodeStruct* List_createNode(int item);
  #endif
  </code></pre>
  
  <p><strong>list.c</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct nodeStruct {
      int item;
      struct nodeStruct *next;
  };
  struct nodeStruct* List_createNode(int item) {
      struct nodeStruct *node = malloc(sizeof(struct nodeStruct));
      if (node == NULL) {return NULL;}
      node-&gt;item = item;
      node-&gt;next = NULL;
      return node;
  }
  </code></pre>
  
  <p><strong>Main.c:</strong></p>
  
  <pre><code>#include "list.h"
  #include &lt;assert.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct nodeStruct *one = List_createNode(1);
  while(one != NULL) {
      printf("%d", one-&gt;item); //error
      one= one-&gt;next; //error
  }
  </code></pre>
  
  <p>Error: <code>error: dereferencing pointer to incomplete type printf("%d", one-&gt;item);
  </code>
  The error is at <code>one-&gt;item</code>, I have tried several combinations to dereference, but does not seem to work. What's the right approach?</p>
  
  <p>Updated:</p>
  
  <p><strong>list.h</strong></p>
  
  <pre><code>#ifndef LIST_H
  #define LIST_H
  
      struct nodeStruct {
      int item;
      struct nodeStruct *next;
  };
  /* Function prototypes */
  struct nodeStruct* List_createNode(int item);
  #endif
  </code></pre>
  
  <p>Now the error is, <code>invalid application of ‘sizeof’ to incomplete type ‘struct nodeStruct’
    struct nodeStruct *node = malloc(sizeof(struct nodeStruct));
  </code> From my list.c file.</p>