What does this point to: cffi.api.FFIError: multiple declarations of constant: __dotdotdot0__

40 views
Skip to first unread message

Sarvi Shanmugham

unread,
May 20, 2015, 12:53:22 AM5/20/15
to pytho...@googlegroups.com

I am seeing the following traceback
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    import sparse
  File "/nobackup/sarvi/spark1/sparse.py", line 39, in <module>
    ffi.cdef(expression._sources)
  File "/nobackup/sarvi/spark1/DebugLNX/root/lib/python2.7/site-packages/cffi-1.0.0-py2.7-linux-x86_64.egg/cffi/api.py", line 107, in cdef
    self._parser.parse(csource, override=override, packed=packed)
  File "/nobackup/sarvi/spark1/DebugLNX/root/lib/python2.7/site-packages/cffi-1.0.0-py2.7-linux-x86_64.egg/cffi/cparser.py", line 166, in parse
    self._internal_parse(csource)
  File "/nobackup/sarvi/spark1/DebugLNX/root/lib/python2.7/site-packages/cffi-1.0.0-py2.7-linux-x86_64.egg/cffi/cparser.py", line 185, in _internal_parse
    self._parse_decl(decl)
  File "/nobackup/sarvi/spark1/DebugLNX/root/lib/python2.7/site-packages/cffi-1.0.0-py2.7-linux-x86_64.egg/cffi/cparser.py", line 263, in _parse_decl
    self._get_struct_union_enum_type('enum', node)
  File "/nobackup/sarvi/spark1/DebugLNX/root/lib/python2.7/site-packages/cffi-1.0.0-py2.7-linux-x86_64.egg/cffi/cparser.py", line 497, in _get_struct_union_enum_type
    tp = self._build_enum_type(explicit_name, type.values)
  File "/nobackup/sarvi/spark1/DebugLNX/root/lib/python2.7/site-packages/cffi-1.0.0-py2.7-linux-x86_64.egg/cffi/cparser.py", line 618, in _build_enum_type
    self._add_constants(enum.name, nextenumvalue)
  File "/nobackup/sarvi/spark1/DebugLNX/root/lib/python2.7/site-packages/cffi-1.0.0-py2.7-linux-x86_64.egg/cffi/cparser.py", line 215, in _add_constants
    "multiple declarations of constant: %s" % (key,))
cffi.api.FFIError: multiple declarations of constant: __dotdotdot0__
make-3.79.1-p7: *** [pysparse] Error 1


The cdefs look like
.......
ffi.cdef(symbol._sources)
ffi.cdef(expression._sources)
.......

Where symbol._sources contains
enum type {
    SYM_UNINITIALIZED=1,
    SYM_PREPROCESSOR,
    SYM_BASETYPE,
    SYM_SIMD_VECTORTYPE,
    SYM_NODE,
    SYM_PTR,
    SYM_FN,
    SYM_ARRAY,
    SYM_STRUCT,
    SYM_UNION,
    SYM_ENUM,
    SYM_TYPEDEF,
    SYM_TYPEOF,
    SYM_MEMBER,
    SYM_BITFIELD,
    SYM_LABEL,
    SYM_NET,
    SYM_NETADDR,
    SYM_HOST,
        SYM_STRING,
    SYM_HOSTADDR,
        SYM_DUALENDIAN,
    SYM_FOULED,
    SYM_KEYWORD,
    SYM_BAD,
    SYM_TYPE_END,
};

Where expressions._sources contains
enum expression_type {
    EXPR_VALUE =...,
    EXPR_STRING,
    EXPR_SYMBOL,
.................


Replacing the "..." with SYM_TYPE_END as in the expression.h does not help either.

Can someone point out what I am doing wrong here?

Thanks,
Sarvi

Armin Rigo

unread,
May 20, 2015, 2:48:06 AM5/20/15
to pytho...@googlegroups.com
Hi Sarvi,

On 20 May 2015 at 06:53, Sarvi Shanmugham <sarv...@gmail.com> wrote:
> Can someone point out what I am doing wrong here?

Again, this looks like a bug. I cannot reproduce it though. Please
provide a self-contained example and post it to the bug tracker...


Armin.

Armin Rigo

unread,
May 20, 2015, 3:31:45 AM5/20/15
to pytho...@googlegroups.com
Re-hi,

Ah, I managed to reproduce it with this code:

ffi = FFI()
ffi.cdef("enum ee2 { EE4=..., EE5=... };")
ffi.cdef("enum ee6 { EE7=10, EE8=..., EE9=... };")

The bug is now fixed. In the meantime, you can solve it by specifying
"..." only once at the end, as in:

enum foo_e { AA, BB, CC, ... };

which has exactly the same effect: any "..." in the enum causes all of
this enum's values to be read from the C compiler.


A bientôt,

Armin.
Reply all
Reply to author
Forward
0 new messages