Wung Hugh Wung Hugh - 7 months ago 31
C Question

Is structure definition available in object file after compiling in c?

Will the compiler make structure definition available in object file? Assume that I don't turn on flags like



In general, no. C has no use for a structure definition once the code is compiled. The compiler will convert all the member references like this...

foo.x = 1;

...to assembly language that only knows that x is a data item of a certain type at a certain offset from the beginning of foo. (Some hardware architectures may use a different addressing mechanism, but it will be conceptually the same.)

It's possible there's a compiler out there that embeds debug symbols in the object file rather than a separate debug file. I'm unaware of any such compilers, but one could exist. However, that's not really the same thing at all. Those symbols would probably only be loaded by a debugger and wouldn't be available to the program itself.