title: python - ctypes, retrieve value of void pointer sent to shared c library
body: <p>Im calling a cpp function from dll with ctypes</p>
  
  <p>the function definition is</p>
  
  <pre><code>int foo(strc *mystrc, int *varsize);
  </code></pre>
  
  <p>And the structure:</p>
  
  <pre><code>typedef struct
  {
      int type;
      int count;
      void *value;
  } strc;
  </code></pre>
  
  <p>So what I tried in python was to define:</p>
  
  <pre><code>class strc(ctypes.Structure):
      _fields_ = [('type', ctypes.c_int),
                  ('count', ctypes.c_int),
                  ('value', ctypes.c_void_p)]
  </code></pre>
  
  <p>And to call the function as</p>
  
  <pre><code>varsize = ctypes.c_int()
  mystrc = strc()
  foo(ctypes.byref(mystrc), ctypes.byref(varsize))
  </code></pre>
  
  <p>I can perfectly call the function and retrieve all values except for the "value". It should be an array of variables indicated by the "type", have size "varsize" and be an array of "count" variables. </p>
  
  <p>How can I retrieve what is indicated by the void pointer?</p>