Click to See Complete Forum and Search --> : how to get the exact size of a function
onlyhuman23
August 12th, 2002, 03:27 PM
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.
Alexey B
August 12th, 2002, 03:45 PM
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.
onlyhuman23
August 12th, 2002, 04:04 PM
isnt there another proper way?
Alexey B
August 12th, 2002, 04:24 PM
If there is, Jeffrey Richter doesn't know about it. My advise was from his book.
poccil
August 12th, 2002, 10:21 PM
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).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.