How to get sizeof

S

sudi

Hi,
If I have a linker map file, is it possible to find sizeof( a structure )
or sizeof( a class) by just looking at the MAP file ? (I don't want to run
the program).

Thanks,
Sudi
 
P

Peter van Merkerk

sudi said:
If I have a linker map file, is it possible to find sizeof( a structure )
or sizeof( a class) by just looking at the MAP file ? (I don't want to run
the program).

Everything that happens after the compilation stage is beyond the scope
of this newsgroup. How linkers should behave and the files they generate
are not defined in the C++ standard. So your question is off-topic in
this newsgroup, and is probably best asked in a newsgroup dedicated to
your development environment.

That being said; whether you can extract the information you want from a
map file depends on the linker you use. But it very unlikely you can
extract the size of a structure or a class itself from a map file. The
map file only tells you what is being put in the executable and the
location of an object inside the executable. Since class definitions are
typically not stored in the executable the map file won't provide any
information about these. Also you won't find local and dynamically
created instances of classes in the map file. However you may be able to
extract the size of global or static instances of a class or structure,
just look for the variable name in the map file.

Probably the easiest way to get the sizeof() information is just to
write a little test program.
 
R

Rolf Magnus

sudi said:
Hi,
If I have a linker map file, is it possible to find sizeof( a
structure ) or sizeof( a class) by just looking at the MAP file ? (I
don't want to run the program).

There is no such thing as a linker map file in Standard C++, so the
answer depends on the linker you use. Ask your question in a newsgroup
dedicated to your platform/compiler/linker/build tools.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top