J
Joseph Wakeling
Hello all,
I sometimes make use of global variables within modules, which I denote
with "static" so that they will not be seen outside the module, and
will preserve values between module calls.
Recently I was looking back at a rather important function and found
I'd forgotten to put the static declaration in place. I'm not worried
about any interference with outside---the variable names are unlikely
to be reproduced elsewhere---but I am *very* concerned that the values
stored in these variables should have been preserved between module
calls. Else it means I have to throw a lot of data away... :-(
Is this latter feature standard for globals in modules, or is the
"static" designation required here? Certainly the results of the code
would seem to suggest the values were preserved. However, it's not
clear to me that this wasn't just the compiler (gcc -O3 -ansi -pedantic
-Wall ...) being nice to me.
Many thanks,
-- Joe
I sometimes make use of global variables within modules, which I denote
with "static" so that they will not be seen outside the module, and
will preserve values between module calls.
Recently I was looking back at a rather important function and found
I'd forgotten to put the static declaration in place. I'm not worried
about any interference with outside---the variable names are unlikely
to be reproduced elsewhere---but I am *very* concerned that the values
stored in these variables should have been preserved between module
calls. Else it means I have to throw a lot of data away... :-(
Is this latter feature standard for globals in modules, or is the
"static" designation required here? Certainly the results of the code
would seem to suggest the values were preserved. However, it's not
clear to me that this wasn't just the compiler (gcc -O3 -ansi -pedantic
-Wall ...) being nice to me.
Many thanks,
-- Joe