Hey there everyone, busy implementing a globals class with all the singletons I need in my "Engine" project. I had handled this differently prior, but felt it needed redoing. My issue now is that my "Game" project links to the engine library, however when I attempt to compile it it moans about the static singletons in the Globals.h being unresolved externals.
This is the rough layout of my Globals.h. I'm not quite sure why I'm getting linkage issues with my "Game" project (which doesn't even use any of the singletons at the moment), yet my "Engine" project compiles perfectly. Anyone have any hints as to why this could be happening?
Static members are different in that declaring them is not enough. You need to define them separately in an implementation file, similarly to a global variable with extern linkage.
You need to put something like this in a .cpp file:
NULL is a macro that's automatically defined for Visual Studio. Sorry, I should've mentioned that. You can define it yourself #define NULL 0 , or* of course you can simply assign 0 to the pointer. If you're using C++11 then you can use the new nullptr constant.