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

Cannot parse enum value refer to previously defined enum value

mozbugbox
created an issue

Refer to an enumeration value defined earlier in the same enumeration failed to parse.

This code failed:

import cffi
ffi = cffi.FFI()
ffi.cdef("enum {a, b, c=b, d};")

because of c=b in the enum definition.

Comments (2)

  1. Armin Rigo

    CFFI only supports immediate constants, like "c=5". Anyway, if you are using verify() afterwards, just say enum { a, b, c, d, ... }; and let CFFI figure out the details. If you're not, then the obvious workaround should be enough: don't define "c" at all in the cdef, and add "lib.c = lib.b" afterwards.

  2. Log in to comment