title: Why do I keep getting "error: variable has incomplete type 'struct intVec'?
body: <p>I'm doing an assignment for my data structures class and I have very little experience with C structures and C in general. 
  This is the .h file that I was given to do the assignment:</p>
  
  <pre><code>#ifndef C101IntVec
  #define C101IntVec
  
  typedef struct IntVecNode* IntVec;
  
  static const int intInitCap = 4;
  
  int intTop(IntVec myVec);
  
  int intData(IntVec myVec, int i);
  
  int intSize(IntVec myVec);
  
  int intCapacity(IntVec myVec);
  
  IntVec intMakeEmptyVec(void);
  
  void intVecPush(IntVec myVec, int newE);
  
  void intVecPop(IntVec myVec);
  
  #endif
  </code></pre>
  
  <p>This is the .c implementation that I've made:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include "intVec.h"
  
  typedef struct IntVecNode {
      int* data;
      int sz;         // Number of elements that contain data
      int capacity;   // How much is allocated to the array
  } IntVecNode;
  
  typedef struct IntVecNode* IntVec;
  
  //static const int intInitCap = 4;
  
  int intTop(IntVec myVec) {
      return *myVec-&gt;data;
  }
  
  int intData(IntVec myVec, int i) {
      return *(myVec-&gt;data + i);
  }
  
  int intSize(IntVec myVec) {
      return myVec-&gt;sz;
  }
  
  int intCapacity(IntVec myVec) {
      return myVec-&gt;capacity;
  }
  
  IntVec intMakeEmptyVec(void) {
      IntVec newVec = malloc(sizeof(struct IntVecNode));
      newVec-&gt;data = malloc(intInitCap * sizeof(int));
      newVec-&gt;sz = 0;
      newVec-&gt;capacity = intInitCap;
      return newVec;
  }
  
  void intVecPush(IntVec myVec, int newE) {
      if (myVec-&gt;sz &gt;= myVec-&gt;capacity) {
          int newCap = myVec-&gt;capacity * 2;
          myVec-&gt;data = realloc(myVec-&gt;data, newCap * sizeof(int));
      } else {
          for (int i = 0; i &lt; myVec-&gt;capacity; i++) {
              *(myVec-&gt;data + i) = *(myVec-&gt;data + i + 1);
          }
          myVec-&gt;data = &amp;newE;
      }
      myVec-&gt;sz++;
  }
  
  void intVecPop(IntVec myVec) {
      for (int i = 0; i &lt; myVec-&gt;capacity; i++) {
          *(myVec-&gt;data - i) = *(myVec-&gt;data - i + 1);
      }
      myVec-&gt;sz--;
  }
  </code></pre>
  
  <p>This is the test file:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include "intVec.c"
  
  int main() {
      struct IntVec v;
      v.intVecPush(v,0);
  
      return 0;
  }
  </code></pre>
  
  <p>Every time I run the test file, I get the error:</p>
  
  <pre><code>test.c:7:16: error: variable has incomplete type 'struct IntVec'
          struct IntVec v;
                        ^
  test.c:7:9: note: forward declaration of 'struct IntVec'
          struct IntVec v;
                 ^
  1 error generated.
  </code></pre>
  
  <p>I've tried changing the <code>#include "intVec.c"</code> to <code>"intVec.h"</code> in the test file, however that produces the same error. What would I need to change in order to not get this error?</p>