1. Python CFFI
  2. Untitled project
  3. cffi
  4. Issues
Issue #67 resolved

enum elements are not available on the lib after dlopen

Antonio Cuni
created an issue

Consider the following code:

import cffi
ffi = cffi.FFI()
ffi.cdef("enum foo { xxx=0, yyy, zzz };")
mylib = ffi.dlopen(None)

if you get the lib through verify(), you can access mylib.{xxx,yyy,zzz}. However, with dlopen you can't.

One possible workaround for the moment is to manually set the attributes on the lib:

mylib.__dict__['xxx'] = int(ffi.cast("enum foo", "xxx"))