[cfe-dev] [cfe-users] Distinguishing between "variable" and "type" declaration

David Röthlisberger david at rothlis.net
Sun Feb 10 08:34:45 PST 2013


On 8 Feb 2013, at 18:22, Nathan Hüsken wrote:
> I am using the python interface for libclang.
> I am getting the cursor for a translation unit and work through all
> childrens.
> 
> Than I am testing with cursor.kind.is_declaration if something is a
> delcaration.
> But now I want to distinguish between variable delcaration and
> declaration for functions, classes (and other types).
> How can I do this?


You can check `cursor.kind`. It will have a value like
`CursorKind.CLASS_DECL`, etc.

BTW are you using ipython? I find ipython's tab-completion is an
excellent way of discovering the libclang API. See for example
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-August/023449.html





More information about the cfe-dev mailing list