In Foo.h I define 1 global variable as
static const int g_var = 4; Then I include this header file in many different header files and .cpp files. If I just write
int g_var = 4; I get errors "g_var already defined in", which is understandable, so I had to add static so it is just initialized once. But using
const int g_var = 4; solves the "already defined in" problem. I read that this is because const global variables have internal linkage by default. So is the keyword static here redundant?
constandstaticcreate internal linkage.