A way to find the size and location of padding in a struct?

前端 未结 10 2500
南笙
南笙 2020-12-16 02:49

I\'m trying to write a tool that will take as input some C code containing structs. It will compile the code, then find and output the size and offset of any padding the com

10条回答
  •  太阳男子
    2020-12-16 03:01

    There is no C++ language feature to iterate through the members of a struct, so I think you're out of luck.

    You might be able to cut down some of the boiler-plate with a macro, but I think you're stuck specifying all the members explicitly.

提交回复
热议问题