Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How to get sizeof

Reply
Thread Tools

How to get sizeof

 
 
sudi
Guest
Posts: n/a
 
      07-27-2004
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
 
Reply With Quote
 
 
 
 
Peter van Merkerk
Guest
Posts: n/a
 
      07-27-2004
sudi wrote:
> 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.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      07-27-2004
sudi wrote:

> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
sizeof( int ) != sizeof( void * ) blufox C Programming 2 05-22-2006 03:25 PM
#define ARR_SIZE sizeof(arr)/sizeof(arr[0]) Vinu C Programming 13 05-12-2005 06:00 PM
sizeof(enum) == sizeof(int) ??? Derek C++ 7 10-14-2004 05:11 PM
sizeof(str) or sizeof(str) - 1 ? Trevor C Programming 9 04-10-2004 05:07 PM



Advertisments