开发者

Can C/C++ compiler report struct member offset [duplicate]

开发者 https://www.devze.com 2022-12-31 17:43 出处:网络
This question already has answers here: Closed 12 years ago. 开发者_运维知识库 Possible Duplicate:
This question already has answers here: Closed 12 years ago. 开发者_运维知识库

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消