* Add #ifdef WIN32 to make main.cpp compile on linux.
[matthijs/ABM2.git] / ABM2 / Engine / singleton.h
index 9a40a95e2f5189d91bd2f1bcb50a168c76cfeddb..748414ad43f9ac475bea4c13f4737d5a4f815e91 100755 (executable)
@@ -11,8 +11,10 @@ class Singleton
                        assert(!ms_singleton);\r
                        //use a cunning trick to get the singleton pointing to the start of the whole, rather than\r
                        //the start of the Singleton part of the object\r
-                       int offset = (int)(T*)1 - (int)(Singleton <T>*)(T*)1;\r
-                       ms_singleton = (T*)((int)this + offset);\r
+                       // This used to say "int" instead of long, but that breaks\r
+                       // on 64 bit linux at least\r
+                       long offset = (long)(T*)1 - (long)(Singleton <T>*)(T*)1;\r
+                       ms_singleton = (T*)((long)this + offset);\r
                }\r
                ~Singleton()\r
                {\r
@@ -33,4 +35,4 @@ class Singleton
 \r
 template <typename T> T* Singleton <T>::ms_singleton = 0;\r
 \r
-#endif
\ No newline at end of file
+#endif\r