[Scummvm-cvs-logs] CVS: scummvm/scumm saveload.h,1.3,1.4
Max Horn
fingolfin at users.sourceforge.net
Sat Sep 21 20:58:01 CEST 2002
Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv6656/scumm
Modified Files:
saveload.h
Log Message:
fixed the non-POD warning for real this time
Index: saveload.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- saveload.h 22 Sep 2002 02:53:15 -0000 1.3
+++ saveload.h 22 Sep 2002 03:57:41 -0000 1.4
@@ -22,8 +22,16 @@
#ifndef SAVELOAD_H
#define SAVELOAD_H
-#define OFFS(type,item) ((int)(&((type*)0)->type::item))
-#define SIZE(type,item) sizeof(((type*)0)->type::item)
+// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
+// we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC
+// versions hae a heuristic built in to detect "offset-of" patterns - which is exactly
+// what our OFFS macro does. Now, for non-POD types this is not really legal, because
+// member need not be at a fixed offset relative to the variable, even if they are in
+// current reality (many of our complex structs are non-POD; for an explanation of
+// what POD means refer to http://www-cpd.fnal.gov/personal/wb/boost/ISOcxx/doc/POD.html)
+
+#define OFFS(type,item) (((int)(&((type*)42)->type::item))-42)
+#define SIZE(type,item) sizeof(((type*)42)->type::item)
#define MKLINE(type,item,saveas) {OFFS(type,item),saveas,SIZE(type,item)}
#define MKARRAY(type,item,saveas,num) {OFFS(type,item),128|saveas,SIZE(type,item)}, {num,0,0}
#define MKEND() {0xFFFF,0xFF,0xFF}
More information about the Scummvm-git-logs
mailing list