Do you mean something like this:
- void PrintInfo(char *Caller,char *Func)
-
{
-
printf("Caller:%s \t Func:%s",Caller,Func);
-
}
-
-
#define CALL(FUNCTION,RET,...){PrintInfo(__FUNCTION__,#FUNCTION);RET=FUNCTION(__VA_ARGS__);}
-
-
It's used like this:
-
-
int Sum(int a,int b,int c)
-
{
-
return a+b+c;
-
}
-
-
void DoWork()
-
{
-
int ret=0;
-
-
CALL(Sum,ret,10,15,20);
-
-
printf("\nSum: %d \n",ret);
-
}
?
So how does this macro works:
This macro uses previously defined function to print(or store info for later use which is what you want to do ).Parameters for that functions are __FUNCTION__ which is the calling function,and second parameter is made by using the preprocessor tokenizer which turns the called function name into a string using the # operator.
Then it calls the function storing the return value if any in RET and passing the variable argument list to it.(Separate macro needed for void functions)