CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2002
    Posts
    8

    Unhappy how to get the exact size of a function

    I have a few functions and their function pointers. I have to display the memory size of those functions. The problem is that if I use sizeof operator on the function pointers they return a constant value. so how then can I get the exact size of a function.

  2. #2
    Join Date
    May 2001
    Posts
    472
    Most compilers and linkers put funtions into the object file in the order in which they appear in the code. Therefore you can put a dummy function after the function the size of which you want to know, than simply substract the adresses.
    Ce n'est que pour vous dire ce que je vous dis.

  3. #3
    Join Date
    Jul 2002
    Posts
    8
    isnt there another proper way?

  4. #4
    Join Date
    May 2001
    Posts
    472
    If there is, Jeffrey Richter doesn't know about it. My advise was from his book.
    Ce n'est que pour vous dire ce que je vous dis.

  5. #5
    Remember that function pointers are just that--pointers. Therefore, they are expected to have the same size as any other pointer in the program (4 or 8 bytes).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured