Heya
How do I use clang to expand macros?
I’ve been able to find the CXCursor enums to do with it, but I’ve not been able to find anything more.
Ideally this would be some sort of operation on a Translation Unit.
Thanks,
Peter
Heya
How do I use clang to expand macros?
I’ve been able to find the CXCursor enums to do with it, but I’ve not been able to find anything more.
Ideally this would be some sort of operation on a Translation Unit.
Thanks,
Peter
You can expand macros in whole translation unit by calling clang -E on source file.
Ah, I’m sorry, I was thinking a bit too in-depth to give all the details I should have - I had meant from in C++ (so using http://clang.llvm.org/doxygen/group__CINDEX.html ).
Thanks, Peter
For C++, I think you should look into clang::Preprocessor [1] and related classes.
[1] http://clang.llvm.org/doxygen/classclang_1_1Preprocessor.html
Colin is using libclang. The question is whether there is an API exposed in libclang that allows you to get the expanded text for a macro instantiation.
David