Victor K
Victor K

Reputation: 559

libclang: how to get compiler macro definitions

With clang LibTooling API one can get a list of compiler predefines simply using clang::Preprocessor::getPredefines(), but I cannot find any equivalent in libclang API. Is it possible to get a list of compiler predefines with libclang API?

Upvotes: 1

Views: 723

Answers (1)

Victor K
Victor K

Reputation: 559

I could list all predefines using the fact that they are present in the beginning of a translation unit. So after parsing I just listed all top-level cursors of CursorKind.MACRO_DEFINITION that are not in any real location (cursor.location.file is None using python bindings API)

Upvotes: 3

Related Questions