Can C/C++ compiler report struct member offset [duplicate]
Possible Duplicate:
Layout of compiled objects
Hello, everyone. I'd like to ask, can compiler(e.g. Visual C++) generate a report(.txt) telling struct member offset for a struct/all structs?
If so, it helps debugging quite a lot. For example, when you read disassembler code in the debugger, it can be easier to associate an offset value to a struct member.
Also, it is better to have compiler report offset of each local variable on a function stack frame(e.g. the offset relative to ebp on an X86 machine).
Thank you in advance.
Thank you, j_random_hacker, you provide a quite feasible answer to my question.
Using undocumented compiler option
/d1reportSingleClassLayoutXXX
/d1reportAllClassLayout
(replace XXX with the class name)
gives us a brief view of struct member offsets.
Tried it on Visual C++ 8 SP1, OK.
I suggest not deleting my question for easy search for others with the same question.
精彩评论