title: Inconsistent declaration and definition in C
body: <p>Today I have spend considerable time finding a "bug" that can be demonstrated by this simple code:</p>
  
  <p><strong>main.c</strong></p>
  
  <pre><code>#include "func.h"
  #include &lt;stdio.h&gt;
  void main(){printf("func: %f", getX());}
  </code></pre>
  
  <p><strong>func.c</strong></p>
  
  <pre><code>#include "func.h"
  static float x[2] = {1.0f, 2.0f};
  float getX(int n){return x[n];}
  </code></pre>
  
  <p><strong>func.h</strong></p>
  
  <pre><code>float getX();
  </code></pre>
  
  <p>and it compiles &amp; links (VS2010 with /W3) without <strong>any warning</strong>. 
  Sample output from the run is </p>
  
  <pre><code>func: 1.000000
  </code></pre>
  
  <p>Can someone explain me how it can work if function declaration and definition do not match and why it is not worth to output any warning? </p>
  
  <p>Thanks</p>