I got a function in a file that works for a single function call. But since it depends on alot of static declarations within this file (I didn't make this file, and its to big to modify). It wont work with multiple function calls.
Is there some way to make each function call unaware of previous calls, or current calls? In effect force a new address space for each functioncall.
like
//file inner.c
#include <stdio.h>
static int counter =1;
int incIt(int a){
counter += a;
return counter;
};
and the main file
//file outer.c
#include <stdio.h>
#include "inner.h"
int main(){
fprintf(stderr,"first: %d\n",incIt(5));
fprintf(stderr,"second: %d\n",incIt(7)); //this should be independent of previous calls.
return 0;
}
compile like
gcc -c inner.c
gcc outer.c
thanks