Using pycparser I encountered a problem with the included headers in the C code I want to parse. For some mysterious reason, some "fake header" works fine and other doesn't work as well. For example, if I include stdint.h, pycparser can parse the code without any problem. However, if I try with stdio.h, I get an error. So, the example code given with pycparser (using_gcc_E_libc.py in the example folder) does not work !
This is what is used in the cited example code :
ast = parse_file(filename, use_cpp=True,
cpp_path='gcc',
cpp_args=['-E', r'-I../utils/fake_libc_include'])
and this is the error I get :
Traceback (most recent call last):
File "/home/patatarte/pycparser/examples/using_gcc_E_libc.py", line 29, in <module>
cpp_args=['-E', r'-I../utils/fake_libc_include'])
File "/usr/lib/python3.4/site-packages/pycparser/__init__.py", line 93, in parse_file
return parser.parse(text, filename)
File "/usr/lib/python3.4/site-packages/pycparser/c_parser.py", line 138, in parse
debug=debuglevel)
File "/usr/lib/python3.4/site-packages/pycparser/ply/yacc.py", line 265, in parse
return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
File "/usr/lib/python3.4/site-packages/pycparser/ply/yacc.py", line 1047, in parseopt_notrack
tok = self.errorfunc(errtoken)
File "/usr/lib/python3.4/site-packages/pycparser/c_parser.py", line 1631, in p_error
column=self.clex.find_tok_column(p)))
File "/usr/lib/python3.4/site-packages/pycparser/plyparser.py", line 54, in _parse_error
raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include/stdarg.h:40:27: before: __gnuc_va_list
Can somebody help me understand why this happens and how I can solve it ?
Thanks in advance !