How to get sizeof

Discussion in 'C++' started by sudi, Jul 27, 2004.

  1. sudi

    sudi Guest

    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
     
    sudi, Jul 27, 2004
    #1
    1. Advertising

  2. 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
     
    Peter van Merkerk, Jul 27, 2004
    #2
    1. Advertising

  3. sudi

    Rolf Magnus Guest

    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.
     
    Rolf Magnus, Jul 27, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Derek
    Replies:
    7
    Views:
    24,416
    Ron Natalie
    Oct 14, 2004
  2. Trevor

    sizeof(str) or sizeof(str) - 1 ?

    Trevor, Apr 3, 2004, in forum: C Programming
    Replies:
    9
    Views:
    662
    CBFalconer
    Apr 10, 2004
  3. Vinu
    Replies:
    13
    Views:
    1,500
    Lawrence Kirby
    May 12, 2005
  4. blufox

    sizeof( int ) != sizeof( void * )

    blufox, May 22, 2006, in forum: C Programming
    Replies:
    2
    Views:
    579
    Joe Smith
    May 22, 2006
  5. Alex Vinokur
    Replies:
    7
    Views:
    513
    Clark S. Cox III
    Aug 14, 2006
Loading...

Share This Page