cffi unistd

19 views
Skip to first unread message

Vladislav Volkov

unread,
Nov 27, 2017, 10:00:49 AM11/27/17
to python-cffi
user@user-pc  ~/Projects/python-MIL-STD-1553B/cffi/lin/abi  master ● ?  python3 ./abi-test.py   
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.5/site-packages/cffi/cparser.py", line 276, in _parse
    ast = _get_parser().parse(fullcsource)
  File "/home/user/.local/lib/python3.5/site-packages/pycparser/c_parser.py", line 152, in parse
    debug=debuglevel)
  File "/home/user/.local/lib/python3.5/site-packages/pycparser/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/home/user/.local/lib/python3.5/site-packages/pycparser/ply/yacc.py", line 1199, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/home/user/.local/lib/python3.5/site-packages/pycparser/ply/yacc.py", line 193, in call_errorfunc
    r = errorfunc(token)
  File "/home/user/.local/lib/python3.5/site-packages/pycparser/c_parser.py", line 1761, in p_error
    column=self.clex.find_tok_column(p)))
  File "/home/user/.local/lib/python3.5/site-packages/pycparser/plyparser.py", line 66, in _parse_error
    raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: /usr/include/unistd.h:290:52: before: __attribute__

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./abi-test.py", line 7, in <module>
    ffi.cdef(fin.read())
  File "/home/user/.local/lib/python3.5/site-packages/cffi/api.py", line 107, in cdef
    self._cdef(csource, override=override, packed=packed)
  File "/home/user/.local/lib/python3.5/site-packages/cffi/api.py", line 121, in _cdef
    self._parser.parse(csource, override=override, **options)
  File "/home/user/.local/lib/python3.5/site-packages/cffi/cparser.py", line 315, in parse
    self._internal_parse(csource)
  File "/home/user/.local/lib/python3.5/site-packages/cffi/cparser.py", line 320, in _internal_parse
    ast, macros, csource = self._parse(csource)
  File "/home/user/.local/lib/python3.5/site-packages/cffi/cparser.py", line 278, in _parse
    self.convert_pycparser_error(e, csource)
  File "/home/user/.local/lib/python3.5/site-packages/cffi/cparser.py", line 307, in convert_pycparser_error
    raise CDefError(msg)
cffi.error.CDefError: parse error
/usr/include/unistd.h:290:52: before: __attribute__



ltmk.h
ltmk.c
api-build.py

Armin Rigo

unread,
Nov 28, 2017, 3:03:59 AM11/28/17
to pytho...@googlegroups.com
Hi,

It seems you have attached "ltmk.h", but your api-build.py tries to
open "_ltmk.h". I think they are different files, because I get an
earlier error with ltmk.h (which makes sense, because #ifdef is not
supported in cdef).


A bientôt,

Armin.

Vladislav Volkov

unread,
Nov 28, 2017, 3:07:54 AM11/28/17
to pytho...@googlegroups.com
Hi

Thanks for answer, but here _ltmk.h = 'gcc -E ltmk.h > _ltmk.h' 

Vladislav


--
-- python-cffi: To unsubscribe from this group, send email to python-cffi+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/python-cffi?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "python-cffi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-cffi/6jH-uJo2jSY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-cffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Armin Rigo

unread,
Nov 28, 2017, 4:50:11 AM11/28/17
to pytho...@googlegroups.com
Hi,

On 28 November 2017 at 09:07, Vladislav Volkov <zloyv...@gmail.com> wrote:
> Thanks for answer, but here _ltmk.h = 'gcc -E ltmk.h > _ltmk.h'

Then it's no surprize it doesn't work. cdef() is not meant to parse
random .h files, but knows only a subset of what you usually put in a
.h file. I would recommend to try simplifying more the "ltmk.h" file,
by hand, until you're left only with type and function declarations
and #define NAME INTEGER_VALUE.


A bientôt,

Armin.
Reply all
Reply to author
Forward
0 new messages