libclang isn't listing all fields of a struct

I have been trying to learn about the AST using python bindings of libclang. But I have not been able to enumerate the fields of a struct successfully. I don’t know if I’m doing it wrong, or if it’s a bug.

Here is the code I wrote:

It simply prints the displayname, spelling, and number of fields of a struct.

And I am running it on the imgui.h file from the project.

For a lot of the structs, I get “fields count: 0”. I wrote an equivalent program in C++. And I got the same result. How do I fix it?

I have cloned the clang repo from the provided git mirror. The latest commit in my clone is:
git commit id: 3b778bc3cec73f904457d70d6f956e1aafe1b550
git-svn-id: 91177308-0d34-0410-b5e6-96231b3b80d8