title: Declaring struct instances as static/local in main() with while(1)
body: <p>I am working on microntroller RZA1, with KPIT GNUARM 16 toolchain, in e2 studio. I am not an expert on the subject, so I'll try to explain the problem the best that I can. The issue is related to a structure <code>mainwindow</code>, defined in my code, which contains important features of the graphical interface:</p>
  
  <pre><code>typedef struct
  {
      page_t      pages[MAXNUMPAGE];
      logger_t    storico;
      messagges_t messaggio;
      graph_t     grafico;
  } mainwindow_t;
  </code></pre>
  
  <p>In the <code>main()</code> function I declare a <code>local</code> instance of this struct, as it contains a <code>while(1)</code> loop, which is used to refresh the GUI application in case of user interaction (i.e pushbutton clicked). The problem that I have encountered is that there's a difference in the way program executes in case the instance of <code>mainwindow_t</code> is declared with or without <code>static</code> keyword. For instance,</p>
  
  <pre><code>main()
  {
      static mainwindow_t mainwindow;
      ....
      init_pages(mainwindow.pages);
      while(1)
      {
          page_update(mainwindow.pages);
      }
  }
  </code></pre>
  
  <p>works perfectly well, whereas with only <code>mainwindow_t mainwindow;</code> it seems that the changes made in the function init_pages() had no effect: entire content of the array page[MAXNUMPAGE] is uninitialized. </p>
  
  <p>Therefore, my question is: should there be any functional difference between non-static local and static local declaration of an array inside a function, if that function basically never returns ? </p>