1

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.

Community
  • 1
  • 1
Jimm Chen
  • 3,411
  • 3
  • 35
  • 59
  • I managed to dig up the undocumented compiler switches, and I've put my answer here: http://stackoverflow.com/questions/2138890/c-see-compiled-object-layout/2902171#2902171. Voting to close your question as a dupe. – j_random_hacker May 25 '10 at 05:16

1 Answers1

1

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.

Jimm Chen
  • 3,411
  • 3
  • 35
  • 59