I am using VC++, and I have problems in defining a global variable. (Please continue reading).
When I define it in a CPP there is no problem, but other file do not know it. I have tried to define it as extern but it didn’t help.
If I define the variable in a header file I get a link error (Symbol already defined in file.obj). I guess I get the error because somehow it is trying to define the variable multiple times. I have tried the following syntax to avoid it, but it didn’t solve the problem:
// Define the variable
Then I define the variable as static. My problems appears to be solved!
Because the global object is static I have other problems with it… (never mind what problem).
How can I define a GLOBAL VARIABLE in a header file without using a static varibale?