title: Clarification of use of structs with Arduino and storing structs in PROGMEM
body: <p><em>(Because of the limited memory available on most Arduino boards, I've sometimes run into problems using valid C/C++ code, so this question is specifically about any issues on using structs on Arduino.)</em></p>
  
  <p>I've seen <a href="http://playground.arduino.cc/Code/ResourceFriendlyStructs">example code of using structs in Arduino</a> but no discussion of memory reqs.</p>
  
  <ol>
  <li>Is the size of a struct simply the sum of the data types of its fields?</li>
  <li>Is storing structs in PROGMEM an option? Are there access speed issues?</li>
  <li>Are the fields of a struct writable (e.g. example below <code>s1.LED1.state = 0;</code>) (though not if stored in PROGMEM, of course).</li>
  <li>Can I define a field of a struct as another (different type) struct? </li>
  <li>Is it possible to iterate through a struct using <code>for..in</code> or by index?</li>
  </ol>
  
  <p>My use case is that I have 64 LEDs driven by a MAX7219 chip. Because of the requirements of the physical wiring layout, it would be convenient to organize the LED order in a more logical way using structs in order to make the programming easier/more coherent.</p>
  
  <hr>
  
  <pre><code>  typedef struct {
        byte row : 6;
        byte col : 128;
        byte state : 1;
      } LED;
  </code></pre>
  
  <hr>
  
  <pre><code> typedef struct {
        LED LED1 : {1,1,1};
        LED LED2 : {1,2,1};
        LED LED3 : {1,4,1};
        LED LED4 : {1,8,1};
        LED LED5 : {1,16,1};
        LED LED6 : {1,32,1};
        LED LED7 : {1,64,1};
        LED LED8 : {1,128,1};
      } LED_SECTION;
  </code></pre>
  
  <hr>
  
  <pre><code>LED_SECTION s1;
  s1.LED1.row = 1;
  </code></pre>
  
  <hr>
  
  <pre><code> s1.LED1.state = 0;
  </code></pre>