title: strategy to declare complex C structured const data?
body: <p>I have a complex data structure (with lots of incomplete array types / heterogenous length arrays of  structures and pointer to structures to arrays of structs ...)</p>
  
  <p>I would like to put those in flash memory, so I thought about putting them in const objects of static storage (they would be stored on flash) and let the compiler do its job.</p>
  
  <p>I'm working on embedded environment, where ROM==flash==data that i cannot physically change. I have few RAM and certainly not enough to store all my data. GCC can be told to put store static const data to ROM with no issues.</p>
  
  <p>The data cannot be constructed dynamically, as it should stay in flash.</p>
  
  <p>I'm currently using C (not C++), with a 4.8 gcc, and don't mind about using GCCisms.</p>
  
  <p>However I keep encoutering error messages like : </p>
  
  <ul>
  <li>initializer element is not constant</li>
  <li>incompatible pointer types</li>
  <li>...</li>
  </ul>
  
  <p>differently with different very recent gcc releases, suggesting this functionality (mixing compound literals, designated initializers , ...) is recent or not mainline.</p>
  
  <p>Note that this code is generated by a program (script).</p>
  
  <p>Besides the errors I keep making (I could be more specific and ask for help there), what strategy would you suggest : </p>
  
  <ul>
  <li>keep trying using complex, nested literal structures using compound literals
  <ul>
  <li>having a massive type compound literal </li>
  <li>having several compound literals types pointing to each other</li>
  </ul></li>
  <li>building many intermediary objects with their names (rendering the whole thing quite unreadable)</li>
  <li><p>building a big uint32_t datablob[] and casting my structures appropriately (with bonus unability to not be able to store pointers between objects as my linker will specify where this will end up)</p></li>
  <li><p>any other options ?</p></li>
  </ul>
  
  <p>(edit : added specifics)</p>
  
  <p>Well, my question was more about a generic strategy, but here is an example : </p>
  
  <pre><code>struct A
  {
      int id; 
      int codes[]; 
  };
  
  struct B 
  {
      int b_member;
      struct A *a[]; // array of ptr to A objects
  };
  
  
  struct C 
  {
      int c_member;
      struct B *objects[]; // array of ptrs on B
  };
  
  const struct A rom_data = { .id=4, .codes = {1,2,3,4}}; // this is in ROM
  
  int main(void) {}
  </code></pre>
  
  <p>I would like to declare like I did for A an array of C structs. (That means I don't want to copy data, read it from disk or malloc it, just declare a const with the data in place.)</p>
  
  <p>All examples I have about literals are very simple.</p>
  
  <p>The specifics of my platform is an ARM microcontroller, but just consider I want to declare a const.</p>