Find size of a function in C

后端 未结 9 1760
别跟我提以往
别跟我提以往 2020-12-10 16:37

I am learning function pointers,I understand that we can point to functions using function pointers.Then I assume that they stay in memory.Do they stay in stack or heap?Can

9条回答
  •  粉色の甜心
    2020-12-10 17:04

    As has been said above, function sizes are generated by the compiler at compile time, and all sizes are known to the linker at link time. If you absolutely have to, you can make the linker kick out a map file containing the starting address, the size, and of course the name. You can then parse this at runtime in your code. But I don't think there's a portable, reliable way to calculate them at runtime without overstepping the bounds of C.

    The linux kernel makes similar use of this for run-time profiling.

提交回复
热议问题