I have a header that declares a set of variables with the extern keyword. Then I have a cpp file responsible for getting the true declarations in. For some reason one of the variables is producing linker errors. Here is how I've done it:
(.h)
...
extern Subsystem **StaticSessions;
...
(.cpp)
...
Subsystem **StaticSessions;
...
I have them in the same namespaces, their names should match, and this is the only variable with the problem. Any ideas?
Ok well I fixed it by taking the actual declaration out of the .cpp it was in, and putting it in the .cpp that was causing the error. Not exactly a fix I am happy with, but at least it's compiling now.
I would assume so, mainly because other global variables declared in the file are working. Just to be safe, I copied the whole thing into a new file that I was sure would compile and same issue: StaticSessions is unresolved at link time unless I put it in orenNetManager.cpp
It doesn't matter what cpp file the definitions are in as long as they're in one.
If you have definitions in one and you're still getting a linker error it's probably because the file they're in is not being linked (ie: it's not added as part of your project). Note that your IDE might not do this by default if you created the file the "wrong" way. (ie: in VS, file | new won't add it to your project, but project | add new item would).
.... It doesn't matter I have it fixed. I'm just saying I have about 10 variables that are being declared like this and this one is the only one not linking, glitch or something I don't know, but since it's working now I am going to call it fixed and move on.