title: Struct vs. Function Definitions in Scope
body: <p>So, as far as I know, this is legal in C:</p>
  
  <p><strong>foo.c</strong></p>
  
  <pre><code>struct foo {
     int a;
  };
  </code></pre>
  
  <p><strong>bar.c</strong></p>
  
  <pre><code>struct foo {
      char a;
  };
  </code></pre>
  
  <p>But the same thing with functions is illegal:</p>
  
  <p><strong>foo.c</strong></p>
  
  <pre><code>int foo() {
      return 1;
  }
  </code></pre>
  
  <p><strong>bar.c</strong></p>
  
  <pre><code>int foo() {
      return 0;
  }
  </code></pre>
  
  <p>and will result in linking error (multiple definition of function <code>foo</code>).</p>
  
  <p>Why is that? What's the difference between struct names and function names that makes C unable to handle one but not the other?
  Also does this behavior extend to C++?</p>