From 5d72701c06df605f9186735adc4df3e025e48668 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 22 Sep 2002 03:57:41 +0000 Subject: fixed the non-POD warning for real this time svn-id: r4999 --- scumm/saveload.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scumm') diff --git a/scumm/saveload.h b/scumm/saveload.h index 46fc145da6..914d6b9346 100644 --- a/scumm/saveload.h +++ b/scumm/saveload.h @@ -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} -- cgit v1.2.3