Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Calculation of size of function

Calculation of size of function

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SanjaySMK
    wrote on last edited by
    #1

    How to calculate the size of a function?

    Software Developer Sanjay Khapre

    M H 2 Replies Last reply
    0
    • S SanjaySMK

      How to calculate the size of a function?

      Software Developer Sanjay Khapre

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      count the lines.


      Maximilien Lincourt Your Head A Splode - Strong Bad

      R 1 Reply Last reply
      0
      • S SanjaySMK

        How to calculate the size of a function?

        Software Developer Sanjay Khapre

        H Offline
        H Offline
        Hans Dietrich
        wrote on last edited by
        #3

        At run time it is difficult to do, unless you have access to the .obj file. If you do, you can parse the file (see Microsoft Portable Executable and Common Object File Format Specification) and look for the size record for the function you are interested in. To experiment with this, take a .obj file that contains a single function, and run this from the command line:

        dumpdin /all myobj.obj > foo.txt

        The file foo.txt will contain a complete dump of the file, and you should see a record that looks like

        0F2 00000000 SECT27 notype () External | ?GetFontProperties@@YAHPBDPAU_tagFONT_PROPERTIES@@@Z (int __cdecl GetFontProperties(char const *,struct _tagFONT_PROPERTIES *))
        tag index 00000106 size 00000C7D lines 0000856D next function 00000111

        In this example, I used the XFont.obj from my XFont article. You can see that the size of GetFontProperties() is given as hex 00000C7D. Note that these sizes are not exact - if you read the PE Format spec, you will find more info. Just out of curiosity, why do you want to do this?

        Best wishes, Hans


        [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

        1 Reply Last reply
        0
        • M Maximilien

          count the lines.


          Maximilien Lincourt Your Head A Splode - Strong Bad

          R Offline
          R Offline
          Russell
          wrote on last edited by
          #4

          lol :-D

          Cheers, Russell

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups