I need to do this but can't figure out how I can implement it.
Tickable.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <list>
#ifdef TICKABLE_EXPORTS //Automatically defined by MSVS
#define DLL __declspec(dllexport)
#else
#define DLL __declspec(dllimport)
#pragma comment(lib, "Tickable.lib")
#endif
class DLL Tickable{
public:
Tickable() //cpp defines to add 'this' pointer to 'subs'
~Tickable() //cpp defines to remove this instance from 'subs'
virtual void Tick(double seconds); //just returns... designed for polymorphism
void static TickAll(double seconds); //runs Tick(double seconds) for all members of 'subs'
private:
static std::list<Ticakble*> subs; //ERROR!
}
|
error LNK2001:
unresolved external symbol "private: static class std::list<class Tickable*,SKIPPED BITS> Tickable::subs" HUGE_SYMBOL_LIST
PATH\Tickable.obj
I know with such a tiny and insignificant class the dll export seems pointless but this class is actually intended to be a .lib ONLY. But it is derived from by .dll style classes, and through inheritance this error is the exact same as what appears in the derived class, I just imagine that the cut down version would be easier to work with.
EDIT: Sorry, forgot to actually state the question (silly me)...
Is it possible to hold either a static variable in a dll which is of a dynamic type,
OR would it be possible to reference an external variable which is static throughout the instances and this variable can be chucked away in a namespace of mine somewhere?
I suppose my only other option (if this is possible) would be to define a maximum instance number and create a standard array of pointers but this could both waste so much memory when not in use and cause problems if I need more memory.