title: ctypes Structure Type Inconsistency
body: <p>There's an inconsistency in ctypes when using structure members versus basic types. The basic types have ctypes type definitions, while structure members get python type definitions. Oddly, I'm able to use assign the python-typed structure members and the values are stored properly in my foreign shared object. Here's my C code:</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  
  unsigned int myvar;
  
  typedef struct
  {
      unsigned int mymember;
  } mystruct_t;
  
  mystruct_t mystruct;
  
  void print(void)
  {
      printf(&quot;myvar=%u\r\n&quot;, myvar);
      printf(&quot;mystruct.mymember=%u\r\n&quot;, mystruct.mymember);
  }
  </code></pre>
  <p>The python code:</p>
  <pre class="lang-python prettyprint-override"><code>import ctypes
  
  class mystruct_t(ctypes.Structure):
      _fields_ = [('mymember', ctypes.c_uint)]
  
  mylib = ctypes.CDLL(&quot;/path/to/mylib.so&quot;)
  
  mylib.print()
  print(&quot;&quot;)
  
  myvar = ctypes.c_uint.in_dll(mylib, &quot;myvar&quot;)
  mystruct = mystruct_t.in_dll(mylib, &quot;mystruct&quot;)
  
  print(type(myvar))
  print(type(mystruct.mymember))
  print(&quot;&quot;)
  
  myvar.value = 1
  mystruct.mymember = 2
  
  mylib.print()
  </code></pre>
  <p>And the output:</p>
  <pre class="lang-text prettyprint-override"><code>myvar=0
  mystruct.mymember=0
  
  &lt;class 'ctypes.c_uint'&gt;
  &lt;class 'int'&gt;
  
  myvar=1
  mystruct.mymember=2
  </code></pre>
  <p>This isn't a major issue, but it's going to cost future developers some time when they run into this. Is there a way around it?</p>