Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma data_seg(".JOE")
- HWND hWndServer = NULL;
- HHOOK hook = NULL;
- #pragma data_seg()
- #pragma comment(linker, "/section:.JOE,rws")
- template <class T> class Foo;
- template<> class Foo<int> {};
- __declspec(dllexport) int Foo<int>::StaticMember = 0;
- map<string,void*> dllexport the_map; // instantiate this once in a single DLL
- T *set_the_global(T *candidate) {
- map<string,void*>::iterator r = the_map.find(string(typeid(the_class<T>).name()));
- if(r == the_map.end()) {
- the_map[string(typeid(the_class<T>).name())] = (void*)candidate;
- return candidate; // new class: use it as global storage location
- } else {
- return (T*)(r->second); // class already has global storage location
- }
- }
- template <class T> class the_class {
- virtual void something(); // so RTTI exists
- static T *the_global; // use this! always points to the same object
- static T one_per_dll; // only used in initialisation
- };
- template<class T> the_class<T>::one_per_dll;
- template<class T> the_class<T>::the_global = set_the_global(&the_class<T>::one_per_dll)
Add Comment
Please, Sign In to add comment