I am trying to parse a C file using pycparser. I am curious to know that while pre-processing the C file does the pycparser reads only those library files which are provided in fake lib folder(if you provide the path of fake lib in cpp_args) or it also reads from the location mentioned in include statements, such as-
in line below
#include<folder1/folder2/xyz.h>
where will the pycparser search for xyz.h will it only be in FAKE LIB folder?
It will search other directories than the fake folder. If you look in the file pycparser/__init__.py
, you'll find a function called preprocess_file
which invokes the C preprocessor on your input file and puts the resulting output in a string, which it then passes to the next function called parse_file
. The code in each of these functions is fairly clear and well-commented, so give it a read and see if it makes sense.
The fake folder is included only for standard library headers like stdlib.h
, stdio.h
and so forth. Those headers often contain non-portable compiler-specific extensions; chances are, you'll only need to know that there's a function printf(...)
in order to be able to parse your code.