I want to know the length of C function (written by me) at runtime. Any method to get it? It seems sizeof doesn\'t work here.
Just subtract the address of your function from the address of the next function. But note it may not work on your system, so use it only if you are 100% sure:
#include
int function() {
return 0;
}
int function_end() {
return 0;
}
int main(void) {
intptr_t size = (intptr_t) function_end - (intptr_t) function;
}