1. Python CFFI
  2. Untitled project
  3. cffi
Issue #114 resolved

The work around for handling of variable length array inside a struct does not work

Anonymous created an issue

Here is a segment of code The library being wrapped has a header file containing the following struct allocation_blob { struct allocation_blob * next; unsigned int left; unsigned int offset; unsigned char data[]; };

Since cffi does not support variable length arrays. I have defined it as follows in my python wrapper cdef struct allocation_blob { struct allocation_blob * next; unsigned int left; unsigned int offset; unsigned char data[0]; };

This does not compile. The error I get is as follows bash-3.00$ LD_LIBRARY_PATH=/ws/sarvi-sjc/mytools/lib:/nobackup/sarvi/sparsenew/sparse/DebugLNX /ws/sarvi-sjc/mytools/bin/python setup.py build In file included from /nobackup/sarvi/sparsenew/sparse/expression.h:14, from /nobackup/sarvi/sparsenew/sparse/parse.h:13, from pycache/_cffi_allocate_xa2b41919xbf262404.c:154: /nobackup/sarvi/sparsenew/sparse/allocate.h:31:1: warning: multi-line comment /nobackup/sarvi/sparsenew/sparse/allocate.h:40:1: warning: multi-line comment In file included from pycache/_cffi_allocate_xa2b41919xbf262404.c:155: /nobackup/sarvi/sparsenew/sparse/allocate.h:31:1: warning: multi-line comment /nobackup/sarvi/sparsenew/sparse/allocate.h:40:1: warning: multi-line comment pycache/_cffi_allocate_xa2b41919xbf262404.c: In function _cffi_layout_struct_allocation_blob': __pycache__/_cffi_allocate_xa2b41919xbf262404.c:1580: error: invalid application ofsizeof' to incomplete type `({anonymous})' Traceback (most recent call last): File "setup.py", line 13, in <module> import expression File "/nobackup/sarvi/sparsenew/sparse/expression.py", line 5, in <module> import allocate File "/nobackup/sarvi/sparsenew/sparse/allocate.py", line 226, in <module> libraries=['sparse',]) File "/ws/sarvi-sjc/mytools/lib/python2.7/site-packages/cffi-0.7.2-py2.7-linux-x86_64.egg/cffi/api.py", line 312, in verify lib = self.verifier.load_library() File "/ws/sarvi-sjc/mytools/lib/python2.7/site-packages/cffi-0.7.2-py2.7-linux-x86_64.egg/cffi/verifier.py", line 68, in load_library self.compile_module() File "/ws/sarvi-sjc/mytools/lib/python2.7/site-packages/cffi-0.7.2-py2.7-linux-x86_64.egg/cffi/verifier.py", line 56, in compile_module self._compile_module() File "/ws/sarvi-sjc/mytools/lib/python2.7/site-packages/cffi-0.7.2-py2.7-linux-x86_64.egg/cffi/verifier.py", line 131, in _compile_module outputfilename = ffiplatform.compile(tmpdir, self.get_extension()) File "/ws/sarvi-sjc/mytools/lib/python2.7/site-packages/cffi-0.7.2-py2.7-linux-x86_64.egg/cffi/ffiplatform.py", line 25, in compile outputfilename = _build(tmpdir, ext) File "/ws/sarvi-sjc/mytools/lib/python2.7/site-packages/cffi-0.7.2-py2.7-linux-x86_64.egg/cffi/ffiplatform.py", line 50, in _build raise VerificationError('%s: %s' % (e.class.name, e)) cffi.ffiplatform.VerificationError: CompileError: command 'gcc' failed with exit status 1

Comments (4)

  1. Log in to comment