title: RuntimeError: ffi_prep_cif failed
body: <p>I am working on a project where I have to use ctypes to call a few C functions from a C file in a Python script. I have created a shared object from the C file and used it inside my Python script.</p>
  
  <p>I have defined the C struct in ctypes, but I am getting a <code>RuntimeError</code> while running my Python script. The error is:</p>
  
  <blockquote>
    <p><code>ffi_prep_cif failed</code></p>
  </blockquote>
  
  <p>I have included ffi.h header in my C file and again created the shared object, but I'm still getting the same error. Any suggestions?</p>
  
  <p>The code which I have written for the wrapper in Python is as follows: </p>
  
  <pre><code>if __name__ == "__main__":
      lib_fib = ctypes.CDLL('./lib6.so')
  
      class model_t(ctypes.Structure):
          _fields__ = [('weight', ctypes.POINTER(ctypes.c_float)),
                       ('threshold', ctypes.c_float)]
  
      data = [1.0, 2.0, 3.0]
      f1 = 2.5
      l = len(data)
      m = model_t()
      m.weight = (ctypes.c_float * l)(*data)
      m.threshold = (ctypes.c_float * 1)(l)
  
      chr_p = ctypes.POINTER(ctypes.c_char)
      c = 'abcd'
      l1 = len(c)
      chr_p = (ctypes.c_char * l1)(*c)
  
      out = lib_fib.new_classify(m, chr_p)
      print out`
  </code></pre>
  
  <p>I am trying to replace Python function called <code>self.abc_prob()</code> with C <code>new_classify()</code>. This is a part of my C function, which I want to call using ctypes:</p>
  
  <pre><code>extern double 
  new_classify(model_t *model_ptr, char *s) 
  {
      char bigram[3];         /* Used only when debugging */
  
      float *model_weights = model_ptr-&gt;weights;
      float threshold = model_ptr-&gt;threshold;
  
      /* ... */
  </code></pre>