I’m using clang ast for a while now to do meta compilation, and I just fell into a problem
when trying to parse vulkan library which has extern “C” in it.
Every symbol inside extern “C” seem to be striped from the TU and ast.
I tried to #undef __cplusplus and this time I got the symbols into the AST.
I first supposed it was a problem with missing includes or else, but clang ouput no errors, and more, now when tracing the files of every symbol in the AST i fall onto some windows headers I never had before #undef of __cplusplus.
Does someone know what goes wrong?
Thanks for your help !
I don’t work on clang but I have used the AST in a project of mine before so please take this with a grain of salt. I believe that an extern “C” block will require you to recurse down it to see the declarations within that block. At least this is what was true of namespaces. In that code (C not C++) my visitor function returned CXChildVisit_Recurse for namespaces. A quick look at the docs would suggest that the cursor kind for extern “C” is CXCursor_LinkageSpec.
Hope that helps!
I don’t have this issue with namespace on my side, and I’m using the clang lib in C++ (clang::ParseAST function), not the cursor based.
Thus, I don’t really know if your solution applies to mine… but thanks, I will dig this as a start !