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

VerificationError and CompileError with unnamed enums and enums as return values

Leonard Ritter
created an issue

For the attached test case, I'm getting a VerificationError exception:

{{{ Traceback (most recent call last): File "app_main.py", line 51, in run_toplevel File "sdlbug.py", line 30, in <module> """, libraries=['SDL2']) File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/api.py", line 269, in verify return self.verifier.load_library() File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/verifier.py", line 55, in load_library self.compile_module() File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/verifier.py", line 42, in compile_module self._write_source() File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/verifier.py", line 95, in _write_source self._vengine.write_source_to_f() File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/vengine_gen.py", line 35, in write_source_to_f self._generate('decl') File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/vengine_gen.py", line 71, in _generate method(tp, realname) File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/vengine_gen.py", line 117, in _generate_gen_function_decl prnt(tp.result.get_c_name(funcdecl)) File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/model.py", line 11, in get_c_name % (result,)) VerificationError: cannot generate 'enum $1 _cffi_f_SDL_RenderTargetSupported(SDL_Renderer* x0)' in a C file: unknown type name }}}

When "typedef enum" is changed to "typedef enum SDL_bool_enum" so that the enum is no longer unnamed, parsing can continue but then hits a compile error:

(out of space, continuing in comments)

Comments (3)

  1. Leonard Ritter reporter

    When "typedef enum" is changed to "typedef enum SDL_bool_enum" so that the enum is no longer unnamed, parsing can continue but then hits a compile error:

    _cffi_gaf81cb26x8b8f4b70.c:42:20: error: return type is an incomplete type
    _cffi_gaf81cb26x8b8f4b70.c: In function ‘_cffi_f_SDL_RenderTargetSupported’:
    _cffi_gaf81cb26x8b8f4b70.c:44:3: warning: ‘return’ with a value, in function returning void [enabled by default]
    Traceback (most recent call last):
      File "app_main.py", line 51, in run_toplevel
      File "sdlbug.py", line 30, in <module>
        """, libraries=['SDL2'])
      File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/api.py", line 269, in verify
        return self.verifier.load_library()
      File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/verifier.py", line 55, in load_library
        self.compile_module()
      File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/verifier.py", line 43, in compile_module
        self._compile_module()
      File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/verifier.py", line 106, in _compile_module
        outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
      File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/ffiplatform.py", line 36, in compile
        outputfilename = _build(ext)
      File "/home/lritter/devel/pypy/site-packages/cffi-0.3-py2.7.egg/cffi/ffiplatform.py", line 60, in _build
        raise VerificationError('%s: %s' % (e.__class__.__name__, e))
    VerificationError: CompileError: command 'cc' failed with exit status 1
    
  2. Armin Rigo

    I could reproduce the first problem; I'll fix it.

    I could not reproduce the second problem. The test case is not self-contained because of "#include <SDL/stuff.h>". Trying to replace this line with some declarations that look reasonable, I don't get any error. I'm guessing that SDL/stuff.h contains "unreasonable" declarations instead :-)

  3. Log in to comment