how to get name of caller function c 2b 2b

Solutions on MaxInterview for how to get name of caller function c 2b 2b by the best coders in the world

showing results for - "how to get name of caller function c 2b 2b"
Cheyenne
12 Apr 2019
1// we'll use __builtin_FUNCTION() to get the name of caller function
2
3#include <iostream>
4
5const char* return_caller(const char* caller = __builtin_FUNCTION()){
6	return caller;
7}
8
9void test(){
10	printf("%s\n",return_caller());
11}
12
13int main(){
14  	test();
15	printf("%s\n",return_caller());
16}
17
18// you can run it in: http://cpp.sh/7beb