static keyword keeps the scope of a global variable limited to that translation unit.
If I use static int x
in a .h file and include that .h file every
The observable difference for variables that are const
qualified is that in the static
version you will get one copy per translation unit and so address comparisons of two such copies may fail.
If you never use the address of your const
variable any modern compiler should be able to just use the value and optimize the variable itself out. In such a case a static
const
-qualified variable is completely fine.