"expected a simple numeric constant" error: line number is missing

Issue #96 new
Francesco Frassinelli
created an issue

This error doesn't show where the problematic code is located.

$ python -c "from cffi import FFI; ffi=FFI(); ffi.cdef(open('nodave_cffi.h').read(), override=True)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/cffi-0.7-py2.7-linux-x86_64.egg/cffi/api.py", line 97, in cdef
    self._parser.parse(csource, override=override)
  File "/usr/lib64/python2.7/site-packages/cffi-0.7-py2.7-linux-x86_64.egg/cffi/cparser.py", line 154, in parse
  File "/usr/lib64/python2.7/site-packages/cffi-0.7-py2.7-linux-x86_64.egg/cffi/cparser.py", line 191, in _internal_parse
    realtype = self._get_type(decl.type, name=decl.name)
  File "/usr/lib64/python2.7/site-packages/cffi-0.7-py2.7-linux-x86_64.egg/cffi/cparser.py", line 322, in _get_type
    return self._get_struct_union_enum_type('struct', type, name)
  File "/usr/lib64/python2.7/site-packages/cffi-0.7-py2.7-linux-x86_64.egg/cffi/cparser.py", line 476, in _get_struct_union_enum_type
    type = self._get_type(decl.type, partial_length_ok=True)
  File "/usr/lib64/python2.7/site-packages/cffi-0.7-py2.7-linux-x86_64.egg/cffi/cparser.py", line 278, in _get_type
    typenode.dim, partial_length_ok=partial_length_ok)
  File "/usr/lib64/python2.7/site-packages/cffi-0.7-py2.7-linux-x86_64.egg/cffi/cparser.py", line 516, in _parse_constant
    raise api.FFIError("unsupported expression: expected a "
cffi.api.FFIError: unsupported expression: expected a simple numeric constant
$ hg log | head -1
changeset:   1300:c268d05a14da

Comments (5)

  1. Armin Rigo

    Indeed, the error message could be better. But it's still easy to figure out where the error is, by killing lines until the error no longer occurs. In this case it's clearly the lines ilke this:

    unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
  2. Pierre Vigneras

    There are two problems actually:

    1. the message could be clearer: provide at least the line number;
    2. supporting such expressions.

    I understand that feature 2. is not as simple as performing an 'eval()' on the expression. However, supporting this feature will help a lot.


  3. Log in to comment