Find holes in C structs due to alignment

后端 未结 7 2573
难免孤独
难免孤独 2021-02-20 18:26

Is there a way in gcc or clang (or any other compiler) to spit information about whether a struct has holes (memory alignment - wise) in it ?

Thank you.

ps: If

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 18:57

    You can use pahole to output information about holes in structures and optionally attempt packing them.

    You may want to read "Poke-a-hole and friends" and the pahole announcement for more information

提交回复
热议问题