If it is static , then the compiler can see that it is used only inside this translation unit, and there is no need to wonder how it is used externally, which is an advantage. If you are not doing anything, this should be the actual variable (for example, by creating a pointer to it), then the compiler will often optimize it.
A friendly approach might use enums
enum { Var1 = 35 };
or in c ++ 11, constexpr
constexpr int Var1 = 35;
They also have the advantage of not messing with a variable of the same name in a different scope if you later had
void f() { int Var1; }
#define will turn it into int 35;
But the difference in memory used will be very small, probably so insignificant that it will never have any noticeable impact on performance unless you are in an extremely limited environment.
source share