K
Kenny McCormack
I'm thinking of writing a tool to analyze C structs - specifically to
generate a mapping between each struct member and its offset (from the
beginning of the struct). The reason for this is that I need to access C
structs from another language that doesn't have structs - it only has
offsets. I can use the offsetof(3) macro to generate the offsets; the
actual problem is generating the list of all the members. In particular, if
members are themselves structs, then you will need to recursively expand
them out.
This doesn't look to be a very difficult project, but I'm curious if there
is already something out there that does it. I.e., to avoid wheel
re-invention...
generate a mapping between each struct member and its offset (from the
beginning of the struct). The reason for this is that I need to access C
structs from another language that doesn't have structs - it only has
offsets. I can use the offsetof(3) macro to generate the offsets; the
actual problem is generating the list of all the members. In particular, if
members are themselves structs, then you will need to recursively expand
them out.
This doesn't look to be a very difficult project, but I'm curious if there
is already something out there that does it. I.e., to avoid wheel
re-invention...