When I try to compile program, in which I have additional classes and one header file for globals, I always get an error LNK2005 which says that I have already defined a value
The only variables that give error are marked with 1,2,3. Now, I tried using static and it didn't give me any error. I also tried using unnamed namespace, and it also didn't give me any error. Can anyone explain me these two, what is the difference, how do they work, and which one to use?
Move those lines to a .cpp file, and replace them in that header with
1 2 3
externbool Start_Game;
externbool Render;
externbool keys[6]; //Not entirely sure about this one
Using static or an anonymous namespace will create separate variables with those names in each translation unit that includes that header, meaning that if you change the value of a variable in one file, the change will only be visible to functions defined in that file. For example,