title: if global variable have default external linkage then why can't we access it directly in another file?
body: <p>I have gone through following questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/4239834/global-variable-in-c-are-static-or-not">Global variable in C are static or not?</a></li>
  <li><a href="https://stackoverflow.com/questions/28610783/are-the-global-variables-extern-by-default-or-it-is-equivalent-to-declaring-vari">Are the global variables extern by default or it is equivalent to declaring variable with extern in global?</a></li>
  </ul>
  
  <p>Above links describe that if we define global variable in one file and haven't specified <code>extern</code> keyword they will be accessible in another source file because of translation unit.</p>
  
  <p>Now I have <code>file1.c</code> in that have defined following global variable and function:</p>
  
  <pre><code>int testVariable;
  
  void testFunction()
  {
      printf ("Value of testVariable %d \n", testVariable);
  }
  </code></pre>
  
  <p>In <code>file2.c</code> have following code</p>
  
  <pre><code>void main()
  {
      testVariable = 40;
      testFunction();
  }
  </code></pre>
  
  <p>Now I am getting  <code>error: 'testVariable' undeclared (first use in this function</code>) -- why?</p>
  
  <p><strong>Note:</strong> both files are used in same program using makefile.</p>
  
  <p>As per my understanding both function and global variable have default external linkage. So function we can use directly by it's name in another file but variable can't why?</p>
  
  <p>Can any one have idea?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>From the below answer i get idea that like in case of function old compiler will guess and add an implicit declaration but in case of variable it can't.  Also C99 removed implicit declaration but still I am getting warning in C99 mode like:</p>
  
  <pre><code>warning: implicit declaration of function ‘testFunction’.
  </code></pre>
  
  <p>Now have gone through below link:</p>
  
  <p><a href="https://stackoverflow.com/questions/11171120/implicit-int-and-implicit-declaration-of-functions-with-gcc-compiler">implicit int and implicit declaration of functions with gcc compiler</a></p>
  
  <p>It said that compiler take it as diagnostic purpose and not give error. So compiler can process forward.</p>
  
  <p>But why in case of variable it can't process further? Even in case of function if compiler proceed and if actual definition not there  then at linking time it will fail. So what's benefit to move forward??</p>