Debian Codegraph @

pycparser223/examples/using_cpp_libc.py

raw symbols SCIP
1 #-----------------------------------------------------------------
2 # pycparser: using_cpp_libc.py
3 #
4 # Shows how to use 'cpp' (the C pre-processor binary) and "fake" libc includes
5 # to parse a file that includes standard C headers.
6 #
7 # Eli Bendersky [https://eli.thegreenplace.net/]
8 # License: BSD
9 #-----------------------------------------------------------------
10 import sys
11
12 # This is not required if you've installed pycparser into
13 # your site-packages/ with setup.py
14 sys.path.extend(['.', '..'])
15
16 from pycparser import parse_file
17
18
19 if __name__ == "__main__":
20 if len(sys.argv) > 1:
21 filename = sys.argv[1]
22 else:
23 filename = 'examples/c_files/year.c'
24
25 ast = parse_file(filename, use_cpp=True,
26 cpp_path='cpp',
27 cpp_args=r'-Iutils/fake_libc_include')
28 ast.show()