Using Global Variables in a Static Library

Currently I can't test it, that's why I'm asking :)

Is it possible to use & change global variables in a Static Library?
For example:

I declare a
bool test = true;
globally.

Then later in an exported function If the user wants, he can set that test to false. So the program later when checks test if it's true, will notice that it's not true, since one of my function changed it.

Is it right?
if you have a program with multiple functions, if a bool is declared outside of them, then each function can use that variable. if it is declared in main, secondary will not detect the variable, and vice versa.


[global declaration]

int main(){
[specific declaration]
}

int secondary(){
[specific declaration]
}
I know what global declaration is, I just wasn't sure if it's working the same way for static libraries too :)

For example:

1
2
3
4
5
6
bool test = true;

void setmyVarTo(bool asd)
{
    test = asd;
}


So if I give this setmyVarTo(bool) in my header to anyone, then (s)he will be able to set this test var which I use?

Well, probably it's a really trivial question, but I'm just not sure if it works :)
Thanks!
When you include the file that contains the function, won't you have the bool test = true; stuck with it ?
Topic archived. No new replies allowed.