title: External, internal and no linkage or why this does not work?
body: <p>According to C standard:</p>
  
  <blockquote>
    <p>In  the  set  of  translation  units  and  libraries  that  constitutes  an  entire  program,  each
    declaration  of  a  particular  identifier  with
    <em>external  linkage</em>
    denotes  the  same  object  or
    function.   Within  one  translation  unit,  each  declaration  of  an  identifier  with
    <em>internal
    linkage</em>
    denotes  the  same  object  or  function.   Each  declaration  of  an  identifier  with
    <em>no
    linkage</em>
    denotes a unique entity.</p>
  </blockquote>
  
  <p>In my example we have three separate declarations with each identifier having a different linkage.So why doesn't this work?</p>
  
  <pre><code>static int a; //a_Internal
  
  int main(void) {
      int a; //a_Local
      {
          extern int a; //a_External
      }
      return 0;
  }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>In function 'main':
    Line 9: error: variable previously declared 'static' redeclared 'extern'</p>
  </blockquote>
  
  <p>Why does compiler insist that I'm redeclaring instead of trying to access external object in another file?</p>
  
  <p>Valid C++ example for reference:</p>
  
  <pre><code>static void f();
  static int i = 0;               // #1
  void g() {
    extern void f();              // internal linkage
    int i;                        // #2 i has no linkage
    {
      extern void f();            // internal linkage
      extern int i;               // #3 external linkage
    }
  }
  </code></pre>
  
  <p>Both Clang and VC seem to be okay with my C example; only some versions of GCC (not all) produce the aforementioned error.</p>