Hi,
I am writing a code generator to generate language bindings in C# for an existing C++ API using clang libtooling.
Our C++ interface has platform specific code. In order to handle this in the code generation, I see two possible approaches.
- Do a build such that all platforms are defined such that all possible code is included in the build
- Run clang libtooling on each platform, and merge the resulting code.
In either case, clang::PPCallbacks looks great for getting preprocessor information.
#if defined (WIN_32)
…
#endif
I have two questions
- It would be a lot easier to run the code generation on one platform, using approach #1 above, while enabling all the platform specific code. The blocker to this issue is that one platform’s specific definitions won’t be available on another platform. Is there a way to invoke clang such that it continues, without error, if it encounters types that it does not recognize?
- While using the PPCallbacks interface, we are notified when a #if, #elif, #else, #endif is present and provided a sourceRange. Is the correct way to determine what was inside these preprocessor definitions to compare the source ranges from the end of the #if to the start of the #endif?
Thanks,
Justin