Using a local variable of the same name in another part of the application
Declaring a variable like this:
int MyVariableName;
creates it as visible across all translation units. Even if you don’t use it as “extern int MyVariableName;” somewhere else, it’s still visible across all files.
If you go and do the same thing again, create a variable of the same name, even though you are only using it locally within that file and aren’t using extern, you’re going to get a GCC “multiple definition of” error because the linker tries to link them together and it’s see a conflict.
It should be static
static int MyVariableName;
The static keyword creates a variable that is not visible across translation units.
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.