1#------------------------------------------------------------------------------- 2# pycparser: using_gcc_E_libc.py 3# 4# Similar to the using_cpp_libc.py example, but uses 'gcc -E' instead 5# of 'cpp'. The same can be achieved with Clang instead of gcc. If you have 6# Clang installed, simply replace 'gcc' with 'clang' here. 7# 8# Eli Bendersky [https://eli.thegreenplace.net/] 9# License: BSD 10#------------------------------------------------------------------------------- 11import sys 12 13# This is not required if you've installed pycparser into 14# your site-packages/ with setup.py 15# 16sys.path.extend(['.', '..']) 17 18from pycparser import parse_file 19 20 21if __name__ == "__main__": 22 if len(sys.argv) > 1: 23 filename = sys.argv[1] 24 else: 25 filename = 'examples/c_files/year.c' 26 27 ast = parse_file(filename, use_cpp=True, 28 cpp_path='gcc', 29 cpp_args=['-E', r'-Iutils/fake_libc_include']) 30 ast.show() 31