(svn r8131) -Fix (r8125): g++ warning: 'invalid access to non-static data member ?<class>::<member>? of NULL object'. It is weird, but renaming the 'offsetof' macro helped.
--- a/src/oldloader.cpp Sun Jan 14 20:00:25 2007 +0000
+++ b/src/oldloader.cpp Sun Jan 14 21:03:21 2007 +0000
@@ -372,7 +372,7 @@
* - OCL_CHUNK: load an other proc to load a part of the savegame, 'amount' times
* - OCL_ASSERT: to check if we are really at the place we expect to be.. because old savegames are too binary to be sure ;)
*/
-#define OCL_SVAR(type, base, offset) { type, 1, NULL, (uint)offsetof(base, offset), NULL }
+#define OCL_SVAR(type, base, offset) { type, 1, NULL, (uint)cpp_offsetof(base, offset), NULL }
#define OCL_VAR(type, amount, pointer) { type, amount, pointer, 0, NULL }
#define OCL_END() { OC_END, 0, NULL, 0, NULL }
#define OCL_NULL(amount) { OC_NULL, amount, NULL, 0, NULL }
--- a/src/saveload.h Sun Jan 14 20:00:25 2007 +0000
+++ b/src/saveload.h Sun Jan 14 21:03:21 2007 +0000
@@ -183,7 +183,7 @@
typedef SaveLoad SaveLoadGlobVarList;
/* Simple variables, references (pointers) and arrays */
-#define SLE_GENERAL(cmd, base, variable, type, length, from, to) {cmd, type, length, from, to, (void*)offsetof(base, variable)}
+#define SLE_GENERAL(cmd, base, variable, type, length, from, to) {cmd, type, length, from, to, (void*)cpp_offsetof(base, variable)}
#define SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to)
#define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to)
#define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to)
--- a/src/stdafx.h Sun Jan 14 20:00:25 2007 +0000
+++ b/src/stdafx.h Sun Jan 14 21:03:21 2007 +0000
@@ -290,9 +290,17 @@
#define lengthof(x) (sizeof(x)/sizeof(x[0]))
#define endof(x) (&x[lengthof(x)])
#define lastof(x) (&x[lengthof(x) - 1])
-#ifndef offsetof
+
+#ifdef offsetof
+# undef offsetof
+#endif
+
+#ifndef __cplusplus
# define offsetof(s,m) (size_t)&(((s *)0)->m)
-#endif
+#else /* __cplusplus */
+# define cpp_offsetof(s,m) (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8)
+# define offsetof(s,m) cpp_offsetof(s, m)
+#endif /* __cplusplus */
// take care of some name clashes on macos