title: C header files and compilation/linking
body: <p>I know that header files have forward declarations of various functions, structs, etc. that are used in the <code>.c</code> file that 'calls' the <code>#include</code>, right? As far as I understand, the "separation of powers" occurs like this:</p>
  
  <p>Header file: <code>func.h</code></p>
  
  <ul>
  <li><p>contains forward declaration of function </p>
  
  <pre><code>int func(int i);
  </code></pre></li>
  </ul>
  
  <p>C source file: <code>func.c</code></p>
  
  <ul>
  <li><p>contains actual function definition</p>
  
  <pre><code>#include "func.h"
  
  int func(int i) {
      return ++i ;
  }
  </code></pre></li>
  </ul>
  
  <p>C source file <code>source.c</code> (the "actual" program): </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "func.h"
  
  int main(void) {
      int res = func(3);
      printf("%i", res);
  }
  </code></pre>
  
  <p>My question is: seeing that the <code>#include</code> is simply a compiler directive that copies the contents of the <code>.h</code> in the file that <code>#include</code> is in, how does the <code>.c</code> file know how to actually execute the function? All it's getting is the <code>int func(int i);</code>, so how can it actually perform the function? How does it gain access to the actual definition of <code>func</code>? Does the header include some sort of 'pointer' that says "that's my definition, over there!"?</p>
  
  <p>How does it work? </p>