Mido Mido
0
Q:

how to get name of caller function c++

// well 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
0

New to Communities?

Join the community