Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get typedef type and name with libclang?

I can get the name and the type of typedefs if they're anonymous structures and the like, but normal typedefs(eg typedef int size_t) I can only get size_t. How can I get the type "int"?

like image 619
Someguynamedpie Avatar asked Oct 27 '25 06:10

Someguynamedpie


1 Answers

Almost a year late, but this is the first result that came up when I was searching for this exact question, so here's a hopefully better answer:

In clang-c/Index.h, the function clang_getTypedefDeclUnderlyingType will get the type the typedef was typedef'd from, and clang_getCursorType gets the type it was typedef'd to. To clarify, for the line:

typedef a b;

clang_getTypedefDeclUnderlyingType returns a, and clang_getCursorType returns b (both as a CXType).

like image 102
cosmicexplorer Avatar answered Oct 29 '25 21:10

cosmicexplorer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!