title: Unknown type name with typedef struct in C
body: <p>This code is written in a file named Monster.c. I have Monster.h defined in both my GameMain.c file and my Monster.c file. Inside the Monster.h file the code is:</p>
  <pre><code>#ifdef MONSTER_H_
  #define MONSTER_H_
  
  int Monster(int Selection);
  EnemyStats MonsterStats(int Selection);
  
  #endif
  </code></pre>
  <p>I then made my typedef struct in the Monster.c file and created the function to return the values for the struct.</p>
  <pre><code>typedef struct EnemyStats
  {
      int EnemyHP;
      int VictoryExp;
      int EnemyLevel;
  }
  EnemyStats;
  
  EnemyStats MonsterStats(int Selection)
  {
      struct EnemyStats value;
  
      switch(Selection)
      {
          case 1:
              value.EnemyLevel = 1;
              value.VictoryExp = 1;
              value.EnemyHP = 1;
              return value;
  
          case 2:
              value.EnemyLevel = 1;
              value.VictoryExp = 1;
              value.EnemyHP = 1;
              return value;
          ...
      }
  </code></pre>
  <p>In the GameMain.c file, I used this code to try and access the information stored in the struct:</p>
  <pre><code>EnemyStats result;
  ...
  printf(&quot;%d&quot;, result.EnemyLevel);
  </code></pre>
  <p>It gives me the error when I use gcc GameMain.c Monster.c</p>
  <blockquote>
  <p>GameMain.c:40:2: error: unknown type name ‘EnemyStats’</p>
  <p>GameMain.c:61:25: error: request for member ‘EnemyHP’ in something not
  a structure or union</p>
  </blockquote>
  <p>If I try to add struct before EnemyStats result; it gives me this error.</p>
  <blockquote>
  <p>GameMain.c: In function ‘main’:</p>
  <p>GameMain.c:40:20: error: storage size of ‘result’ isn’t known</p>
  </blockquote>
  <p>I am unsure of what I am doing wrong. Any help is appreciated.</p>
  <p><em>For anybody who does not know, I am using ... to say that I am skipping code that does not affect the situation I am describing or the code is redundant</em></p>