title: C requires that a struct or union has at least one member
body: <p>I'm getting a bunch of weird errors from the compiler when I try to compile this code.</p>
  
  <p>I'm just trying to write a basic linked list, and the header file compiles fine when run on its own but when I compile the c file everything falls apart</p>
  
  <p>linkedlist.h</p>
  
  <pre><code>typedef struct Data
  {
      char *title;
  } Data;
  
  typedef struct LinkedList
  {
      LinkedList *next;
      Data *data;
  } LinkedList;
  
  LinkedList *createnew(void);
  void destroylist(LinkedList *old);
  Data *adddata(void);
  void destroydata(Data *old);
  </code></pre>
  
  <p>LinkedList.c</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include "linkedlist.h"
  
  LinkedList *createnew(void) {
      LinkedList *newnode = (LinkedList *) malloc(sizeof(LinkedList));
      newnode-&gt;data = adddata();
      newnode-&gt;next = NULL;
      return newnode;
  }
  
  void destroylist(LinkedList *old) {
      destroydata(old-&gt;data);
      free(old);
      return;
  }
  
  Data *adddata(void) {
      Data *newdata = (Data *) malloc(sizeof(Data));
      newdata-&gt;title = NULL;
      return newdata;
  }
  
  void destroydata(Data *old) {
      free(old-&gt;title);
      free(old);
      return;
  }
  </code></pre>
  
  <p>and finally what the compiler spits out</p>
  
  <pre><code>linkedlist.h(8): error C2016: C requires that a struct or union has at least one member
  linkedlist.h(8): error C2061: syntax error : identifier 'LinkedList'
  linkedlist.h(10): error C2059: syntax error : '}'
  linkedlist.h(12): error C2143: syntax error : missing '{' before '*'
  linkedlist.h(13): error C2143: syntax error : missing ')' before '*'
  linkedlist.h(13): error C2143: syntax error : missing '{' before '*'
  linkedlist.h(13): error C2059: syntax error : ')'
  linkedlist.c(4): error C2143: syntax error : missing '{' before '*'
  linkedlist.c(5): error C2065: 'LinkedList' : undeclared identifier
  linkedlist.c(5): error C2065: 'newnode' : undeclared identifier
  linkedlist.c(5): error C2059: syntax error : ')'
  linkedlist.c(6): error C2065: 'newnode' : undeclared identifier
  linkedlist.c(6): error C2223: left of '-&gt;data' must point to struct/union
  linkedlist.c(7): error C2065: 'newnode' : undeclared identifier
  linkedlist.c(7): error C2223: left of '-&gt;next' must point to struct/union
  linkedlist.c(8): error C2065: 'newnode' : undeclared identifier
  linkedlist.c(8): warning C4047: 'return' : 'int *' differs in levels of indirection from 'int'
  linkedlist.c(11): error C2143: syntax error : missing ')' before '*'
  linkedlist.c(11): error C2143: syntax error : missing '{' before '*'
  linkedlist.c(11): error C2059: syntax error : ')'
  linkedlist.c(11): error C2054: expected '(' to follow 'old'
  </code></pre>
  
  <p>I'm confused because it looks like it finds both files but then it has trouble with the header even though it works fine alone.
  Any help would be great.
  Thanks</p>