I have a very similar question to: Macro and function with same name
I want a macro to only change the function call and not the function itself
#define original_function(a, b) replace_function(a, b)
uint64_t replace_function(int a, int b) {
// some functionality
}
uint64_t original_function(int a, int b) {
// some functionality
}
uint64_t main(uint64_t argc, uint64_t* argv) {
original_function(10, 20);
}
this would result in changing the original function definition
#define original_function(a, b) replace_function(a, b)
uint64_t replace_function(int a, int b) {
// some functionality
}
uint64_t replace_function(int a, int b) {
// some functionality
}
uint64_t main(uint64_t argc, uint64_t* argv) {
original_function(10, 20);
}
I cannot do this (which is the answer in the linked question)
uint64_t (original_function)(int a, int b) {
// some functionality
}
//...
And I cannot put the definition after the function
uint64_t original_function(int a, int b) {
// some functionality
}
#define original_function(a, b) replace_function(a, b)
// ...
Is it somehow possible to define in the macro to only change function calls and not function definitions? Or can I somehow define a macro to rename only the original function (not the call) so it won't be affected?
Edit: I can only change the macro not the code after that...