sighingnow / libclang

(Unofficial) Release libclang (clang.cindex) on pypi.
https://pypi.org/project/libclang
Other
85 stars 23 forks source link

The recognition error regarding CursorKind for class and namespace. #68

Open Fengxiaoxx opened 10 months ago

Fengxiaoxx commented 10 months ago

Hello, I've encountered an issue while parsing the AST of header files using the libclang library. It seems that all class and namespace CursorKind are recognized as VAR_DECL. Is there any solution to this problem?The correct solution is to use CursorKind.CLASS_DECL for classes and CursorKind.NAMESPACE_DECL for namespaces.Looking forward to your reply! libclang

JhnW commented 10 months ago

Hi. Please check parsing errors: print(your_cursor.translation_unit.diagnostics) There you will see a list of parse errors, identical to the compiler's. In your case the case is clear, you are missing include to std::string. This is the first step, it should usually help, but on some Linux systems it may not be enough (in my clangtools package, Devana, I provide the libcxx header for this reason).