title: How can I tell Visual Studio/Microsoft's C compiler to allow variable declarations after the first statement?
body: <p>I have code that compiles on the GNUARM compiler, but Visual Studio 2010 issues errors. The issue involves declaring variables after the first statement in a C language file:</p>
  <h3>main.c</h3>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void)
  {
    int i = 6;
    i = i + 1;
    printf(&quot;Value of i is: %d\n&quot;, i);
    int j = i * 10; // &lt;-- This is what Visual Studio 2010 complains about.
    printf(&quot;Value of j is: %d\n&quot;, j);
    return EXIT_SUCCESS;
  }
  </code></pre>
  <p>The following code compiles without errors:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void)
  {
    int i = 6;
    int j;      // &lt;-- Declaration is now here, valid according to K&amp;R rules.
    i = i + 1;
    printf(&quot;Value of i is: %d\n&quot;, i);
    j = i * 10; // &lt;-- Moved declaration of j to above.
    printf(&quot;Value of j is: %d\n&quot;, j);
    return EXIT_SUCCESS;
  }
  </code></pre>
  <p>I'm using default settings for creating a Win32 console project. When I set &quot;Compile as&quot; property to &quot;Compile as C++ (/TP)&quot;, I get compilation errors in some Visual Studio header files. (Right click on project, choose <em>Properties</em> → <em>Configuration Properties</em> → <em>C/C++</em> → <em>Advanced</em>).</p>
  <p>How do I tell Visual Studio 2010 to allow variable declarations after the first statement, like C++ or the current C language standard?</p>