I am wondering if how I can write a function to detect the parameter type, value and function name and return value of another function.
For example. I have a function:
double average(string datapath, double *data, int numofinput)
{
// some code here
}
I want to have another function, such as detector(), which can be inserted into the function to be detected, like
double average(string datapath, double *data, int numofinput)
{
// some code here
detector();
}
and the detector will return:
name: average
returned value: 2.43
pathname: string='C:/Users/Nick/Data/'
data: pointer=0x0065
numofinput: int=17
Somthing like that. Any suggestion is highly appreciated. Thanks.
Nick
In general this can’t be done:
detectorwould need to show the return value before you actually return anything, which is same as mind readingaveragefunction might not be a function at all, as compiler could inline it.For specific cases, however, you could be able to get this information – under assumption that you have debug symbols available, which in general you don’t.