Rolf Kalbermatter wrote:
There is a huge distinction between static and const. static is allocated on the heap as global as you say and that means bad things will happen when the function is called in parallel from several threads.
const basically is only a compiler restriction which prevents the programmer to change the value of a variable after it is initialized. That's why you had to remove it as otherwise the compiler complained that the variable assignement later on would not be valid. But the const variable is still allocated on the stack and therefore threadsafe.
Rolf Kalbermatter
Ah, yes, I know what const and static do. I was just thinking that const was a global as well as static .... I must be thinking C++/constructors and be getting confused.
So just plain INT is is.