title: const struct declaration
body: <p>Can someone tell me the difference between these two versions of a declaration of a structure?</p>
  
  <pre><code>struct S
  {
    uint8_t a;
  };
  </code></pre>
  
  <p>and</p>
  
  <pre><code>const struct S
  {
    uint8_t a;
  }
  </code></pre>
  
  <p>Followed by:</p>
  
  <pre><code>void main(void)
  {
    struct S s = {1};
    s.a++;
  }
  </code></pre>
  
  <p>Hint, i've tried both versions for S in Visual Studio C++ 2010 Express so I know that both compile with errors.</p>
  
  <p>Is the "const struct" doing nothing at all? "const struct S s = {1};" certainly does, but that's not the issue at the moment.</p>
  
  <p>Regards
  Rich</p>
  
  <pre><code>/********************************************/
  </code></pre>
  
  <p>I've just worked out what</p>
  
  <pre><code>const struct &lt;typename&gt; &lt;{type}&gt; &lt;variable instances a, b, .., z&gt;;
  </code></pre>
  
  <p>is doing:</p>
  
  <p>When const is present before the "struct", all variable instances are const, as though they'd be defined with:</p>
  
  <pre><code>const struct &lt;typename&gt; a, b, z;
  </code></pre>
  
  <p>So it does do something, but not when there's no instance definitions in-line with the struct declaration.</p>
  
  <p>Rich</p>