If a project has below code:
function.h
#include <stdio.h>
extern void function_a();
extern void function_b();
function.c
#include <stdio.h>
#include "function.h"
void function_a() {
printf("This is function a!\n");
}
void function_b() {
printf("This is function b!\n");
}
main.c
#include <stdio.h>
#include "function.h"
#define function_b function_a
void function_c() {
function_a();
function_b();
}
#undef function_b
int main() {
function_a();
function_b();
function_c();
return 0;
}
What do you think the result is?
> gcc main.c function.c
> ./a.out
This is function a!
This is function b!
This is function a!
This is function a!
It means you can change the function name before compiling the program, and do things more like:
Call the specific function instead of the origin one to avoid a lot of modification to the code.