Getting The Size of a C++ Function

后端 未结 16 2137
醉酒成梦
醉酒成梦 2020-12-06 09:37

I was reading this question because I\'m trying to find the size of a function in a C++ program, It is hinted at that there may be a way that is platform specific. My target

16条回答
  •  温柔的废话
    2020-12-06 10:15

    There is no facilities in Standard C++ to obtain the size or length of a function.
    See my answer here: Is it possible to load a function into some allocated memory and run it from there?

    In general, knowing the size of a function is used in embedded systems when copying executable code from a read-only source (or a slow memory device, such as a serial Flash) into RAM. Desktop and other operating systems load functions into memory using other techniques, such as dynamic or shared libraries.

提交回复
热议问题