Update static global variable from another file in c -


update static variable outside of file without modifying file in static variable declared in c lang.

proj1 creates dll. proj1 has abc.h file , defined below :

static bool stvar = false;//declared global static variable  func1() {     stvar= true; }  func2() {     if(stvar == true)     {         ....     }     else     {         func1();  //call func1 sets stvar = true;     } } 

proj2 creates exe. has cprog1.c file. cprog1.c file defined follows:

cprogfunc1() {     func2(); //call func2 sets stvar = true; }  cprogfunc2() {     stvar = false;     func2(); } 

we setting stvar false in cprogfunc2() make execute else block in func2() of abc.h file. value set in cprogfunc2() under cprog1.c not reflected in abc.h file. updating static variable outside declaration because cannot modify under proj1. please suggest ways update static variable cprog1.c file without modifying abc.h/proj1. if not possible suggest workaround. thanks.

solutions tried :

  1. making stvar non static - not possible since can not modify abc.h file
  2. using pointers - did not work

by definition, stvar made static in order limit accessibility it, meaning ideal way tinker outside create api (or indeed make global, not static). since editing proj1 out of question, left bad situation.

what reset proj1's state freeing dll , loading again, mention here.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -