libtool for some preprocessor work

Hello

I am trying to create a visual map of some source code to be able to do source to source transformation.

The first thing that I would like to do is be able to get a list of all the #include statements from the c source code.

Once that’s done, I would also need to be able to go through all the variables defined in the main source file and see if it’s being defined in said file or being linked in from some of those header files.

This should be enough to get me well under way with my project. I came across libclang because it’s stable and it’s also written in c; the language that I will be working with.

My question; how can I get the list of include files from the main file, then searching for variables; if they are defined in an include file or are they local to the main file?

Best,
Owen

Hello,

Have a look at clang::PPCallbacks ()

Have a look at pp-trace for an example how to use it.

Best,
David

Hello David

Thank you for the reference. I just had a chance to look at it, seems great!

Best,
Owen