[gcc plugin] get member offset in struct just like offsetof

dotpy dotpy2@163.com
Tue Feb 6 15:25:00 GMT 2018


Hi experts,



I am writing a gcc plugin for parsing the structure fields. But I have the problem how to get the offset of each field in the struct? Just like the offsetof macro in gcc.

I see DECL_FIELD_OFFSET in tree.h, but the result seems not right.

My test program could be found in stack overflow:

https://stackoverflow.com/questions/48582971/gcc-plugin-to-implement-offsetof




Could someone explain what is DECL_FIELD_OFFSET used for, and how to implement offsetof?




Thanks


More information about the Gcc mailing list