how to get name of caller function cpp code example
Example: how to get name of caller function c++
// we'll use __builtin_FUNCTION() to get the name of caller function
#include <iostream>
const char* return_caller(const char* caller = __builtin_FUNCTION()){
return caller;
}
void test(){
printf("%s\n",return_caller());
}
int main(){
test();
printf("%s\n",return_caller());
}
// you can run it in: http://cpp.sh/7beb