title: How do you declare a struct in a header file and define it in the .c file
body: <p>I just need a simple direct answer to this, but I haven't been able to get any online.</p>
  <p>Why do I get an error when I write the following in the <code>person.h</code> file:</p>
  <pre class="lang-c prettyprint-override"><code>typedef struct Person Person_T;
  </code></pre>
  <p>And the following the the <code>person.c</code> file:</p>
  <pre class="lang-c prettyprint-override"><code>typedef struct Person
  {
    char *name;
    unsigned int age;
  } Person_T;
  </code></pre>
  <p>EDIT: For reference, this is my <code>main.c</code> file:</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &quot;person.h&quot;
  
  int main()
  {
    Person_T sam = { &quot;Sam&quot;, 24 };
    printf(&quot;%s, %d\n&quot;, sam.name, same.age);
  
    return 0;
  }
  </code></pre>
  <p>And the error is <code>variable has incomplete type Person_T (aka 'struct Person')</code></p>
  <p>Two more related questions:</p>
  <ul>
  <li>Why do some people write something like <code>extern struct Person Person;</code> or something like that?</li>
  <li>When should I define my structs and functions in the header file, or rather go header-only in a library?</li>
  </ul>
  <p>Sorry, I'm new.</p>