title: How do I emulate a dynamically sized C structure in Python using ctypes
body: <p>I'm writing some python code to interact with a C DLL that uses structures extensively.</p>
  
  <p>One of those structures contains nested structures.  I know that this is not a problem for the ctypes module.  The problem is that there is an often used structure that, in C, is defined via macro because it contains an "static" length array that can vary.  That is confusing so here's some code</p>
  
  <pre><code>struct VarHdr {
      int size;
  }
  
  #define VAR(size) \
      struct Var {
          VarHdr hdr;
          unsigned char Array[(size)];
      }
  </code></pre>
  
  <p>Then it is used in other structures like this</p>
  
  <pre><code>struct MySruct {
      int foo;
      VAR(20) stuffArray;
  }
  </code></pre>
  
  <p>The question then becomes how can I emulate this in Python in a way that the resulting structure can be passed back and forth between my pythong script and the DLL.  </p>
  
  <p>BTW, I know that I can just hardcode the number in there but there are several instances of this "VAR" throughout that have different sizes.</p>