title: c - static & non-static variable in assmebly
body: <p><strong>Question 1</strong>: Is the following statement correct: <br ></p>
  
  <blockquote>
    <p>In c file, a variable outside function which is not marked as static has scope from it's definition to end of the file.</p>
  </blockquote>
  
  <p><strong>Question 2</strong>: If the answer to question 1 is <strong>true</strong>, then when the c program compiled to assembly code, in which section does the variable metioned in question 1 stored?</p>
  
  <p>@Edit:</p>
  
  <blockquote>
    <p>I ask this question because I am a little confused about variable marked with static and variable not marked with static. What is the underling different in assembly for this 2 kind of variable, where are they stored? If they both stored at the data section, then how does c make sure the variable marked with static is only visible to the file that define it.</p>
  </blockquote>
  
  <hr>
  
  <p>@Answer:</p>
  
  <blockquote>
    <p>According to answer &amp; comment of <strong>@Vlad from Moscow</strong>, the answer to question 1 is true, the answer to question 2 is "data section", and the reason that staic variable is only visible to the file defined it is that static variable has internal linkage to make sure it is not visible outside the compilation unit where it is declared.</p>
  </blockquote>