Answers for "how to get name of caller function c++"

C++
1

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
Posted by: Guest on December-03-2020

Code answers related to "how to get name of caller function c++"

Browse Popular Code Answers by Language