diff options
-rwxr-xr-x | TODOS | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | src/NonCopyable.hpp | 12 | ||||
-rwxr-xr-x[-rw-r--r--] | src/Singleton.hpp | 0 | ||||
-rwxr-xr-x | tests/modules/Common.hpp | 10 | ||||
-rwxr-xr-x | tests/modules/Makefile.W32 | 2 | ||||
-rwxr-xr-x | tests/modules/testmod2/Makefile.W32 | 3 |
6 files changed, 33 insertions, 5 deletions
@@ -1,5 +1,14 @@ - singleton with registered pointers, so they can be shared between - loadable modules on Windows, example is the logger singleton currently + loadable modules on Windows, example is the logger singleton currently: + - exported data segments + #pragma data_seg("SHARED") + #pragma data_seg() + #pragma comment(linker, "/section:SHARED,RWS") + - http://support.microsoft.com/kb/168958/en-us + - http://www.xing.com/net/moderncpp/allgemeines-zu-c-101269/singletons-in-dll-s-32375749 + - http://stackoverflow.com/questions/1880052/c-duplicated-static-member + - http://stackoverflow.com/questions/4911994/sharing-a-global-static-variable-between-a-process-and-dll + - http://www.ogre3d.org/forums/viewtopic.php?p=75622&sid=ce193664e1d3d7c4af509e6f4e2718c6 - rewrite logger as proper singleton - use traits in rewindinputstream, alternative wrappers for char/string traits depending on underlying io stream diff --git a/src/NonCopyable.hpp b/src/NonCopyable.hpp index de43d5d..f56802c 100644..100755 --- a/src/NonCopyable.hpp +++ b/src/NonCopyable.hpp @@ -3,8 +3,16 @@ namespace __dont_touch { - -class noncopyable + +#ifndef SHARED +#define SINGLETON_EXPORT __declspec(dllexport) +#define SINGLETON_EXTERN +#else +#define SINGLETON_EXPORT __declspec(dllimport) +#define SINGLETON_EXTERN extern +#endif + +class SINGLETON_EXPORT noncopyable { protected: noncopyable( ) { } diff --git a/src/Singleton.hpp b/src/Singleton.hpp index 2bdf257..2bdf257 100644..100755 --- a/src/Singleton.hpp +++ b/src/Singleton.hpp diff --git a/tests/modules/Common.hpp b/tests/modules/Common.hpp index dc1f22a..4be89bb 100755 --- a/tests/modules/Common.hpp +++ b/tests/modules/Common.hpp @@ -20,4 +20,14 @@ class Common : public Singleton< Common > void print( string s ) { cout << m_name << ": " << s << endl; } }; +#ifndef SHARED +#define SINGLETON_EXPORT __declspec(dllexport) +#define SINGLETON_EXTERN +#else +#define SINGLETON_EXPORT __declspec(dllimport) +#define SINGLETON_EXTERN extern +#endif + +SINGLETON_EXTERN template class SINGLETON_EXPORT Singleton< Common >; + #endif diff --git a/tests/modules/Makefile.W32 b/tests/modules/Makefile.W32 index 8a745a0..6dfa78b 100755 --- a/tests/modules/Makefile.W32 +++ b/tests/modules/Makefile.W32 @@ -27,7 +27,7 @@ OBJS = test1.exe: test1.obj test2.exe: test2.obj -local_all: +local_all: test2.exe local_clean: @-erase -f *.RES *.DIFF *.ERR 2>NUL diff --git a/tests/modules/testmod2/Makefile.W32 b/tests/modules/testmod2/Makefile.W32 index 9640019..f1ae5e1 100755 --- a/tests/modules/testmod2/Makefile.W32 +++ b/tests/modules/testmod2/Makefile.W32 @@ -15,7 +15,8 @@ INCLUDE_DIRS = \ INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ - $(TOPDIR)\src\crawler.lib + $(TOPDIR)\src\crawler.lib \ + ..\test2.lib DYNAMIC_MODULE = \ mod_test2.dll |