I have this big project that contains dozens of .c file. I want to add a global variable to each file without changing the source code. Is there anyway I can do that? Maybe with a wrapper function or in MakeFile? I appreciate any help.
Sorry didn't make it clear. What I meant was for example, I want to add a variable called int x to each file, and then I want to use a wrapper function __wrap_foo(int a, int x) to replace the original function foo(int a), while foo(int a) may or may not be used in each file. The reason I'm trying to add it as a global variable in each file is that __wrap_foo may not be the only wrapper function that want to use value int x. There might be other wrappers like __wrap_zoo(double b, int x) also uses and modifies the value of x. I hope this makes more sense.