title: Is it possible to declare multiple static variables with same name in a single C file?
body: <p>Is it possible to declare multiple static variables of same name in a single C file with different scopes?
  I wrote a simple programme to check this and in gcc it got compiled and worked fine.</p>
  
  <p>Code:</p>
  
  <pre><code>static int sVar = 44;
  
  void myPrint2()
  {
      printf("sVar = %d\n", sVar++);
  }
  
  void myPrint()
  {
      static int sVar =88;
      printf("sVar = %d\n", sVar++);
  }
  
  int main(void)
  {
      static int sVar = 55;
      int i = 0;
      for (i = 0; i &lt; 5; i++)
          myPrint();      
      printf("sVar = %d\n", sVar);
      myPrint2();
      return(0);
  }
  </code></pre>
  
  <p>Now my question is since all "static" variable will reside in same section (.data) then how we can have multiple variables with same name in one section?</p>
  
  <p>I used <code>objdump</code> to check the different section and found that all the static variables (<code>sVar</code>) were in .data section but with different names:</p>
  
  <pre><code>0804960c l     O .data  00000004              sVar
  08049610 l     O .data  00000004              sVar.1785
  08049614 l     O .data  00000004              sVar.1792
  </code></pre>
  
  <p>Why is the compiler is changing the name of the variables (since C doesn't support name mangling)?</p>