Reputation: 29
Can anyone please solve the following problem for me:
Problem: Let say there are two functions foo()
and bar()
defined as
void bar()
{
printf("bar\n");
}
void foo()
{
printf("foo\n");
bar();
}
So, here I want to change the function name bar to bar_test in its definition but not in calling. This should be runtime and the source code should not be modified.
The expected output is as below:
void bar_test()
{
printf("bar\n");
}
void foo()
{
printf("foo\n");
bar();
}
Thanks
Upvotes: 2
Views: 8408
Reputation: 19864
One way would be to have a macro like
#define bar() bar_test()
Now calling bar()
by the macro calls bar_test()
The function which is defined should be called as per the standard. There is no option to change the function name during runtime and it doesn't make sense also.
Upvotes: 5