From e7165f8f0d623123d197ef1b833c045e3cab7a8b Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 9 Nov 2014 10:31:44 -0500 Subject: [PATCH] Port offsetof "fix" from sdk2013. --- public/datamap.h | 4 ---- public/studio.h | 3 --- public/tier0/platform.h | 10 ++++++++++ public/vgui_controls/MessageMap.h | 4 ---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/public/datamap.h b/public/datamap.h index 282d4f19..c8e024a5 100644 --- a/public/datamap.h +++ b/public/datamap.h @@ -110,10 +110,6 @@ DECLARE_FIELD_SIZE( FIELD_MODELINDEX, sizeof(int) ) DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) ) -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - #define ARRAYSIZE2D(p) (sizeof(p)/sizeof(p[0][0])) #define _FIELD(name,fieldtype,count,flags,mapname,tolerance) { fieldtype, #name, { offsetof(classNameTypedef, name), 0 }, count, flags, mapname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, tolerance } diff --git a/public/studio.h b/public/studio.h index 37d6cf31..c24da1ba 100644 --- a/public/studio.h +++ b/public/studio.h @@ -23,9 +23,6 @@ #include "utlvector.h" -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif //----------------------------------------------------------------------------- diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 16c31c7e..62356d8c 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -223,6 +223,16 @@ typedef void * HINSTANCE; #define MAX_PATH 260 #endif + +#ifdef GNUC +#undef offsetof +//#define offsetof( type, var ) __builtin_offsetof( type, var ) +#define offsetof(s,m) (size_t)&(((s *)0)->m) +#else +#undef offsetof +#define offsetof(s,m) (size_t)&(((s *)0)->m) +#endif + // Used to step into the debugger #ifdef _WIN32 #define DebuggerBreak() __asm { int 3 } diff --git a/public/vgui_controls/MessageMap.h b/public/vgui_controls/MessageMap.h index ed768a96..677bddb9 100644 --- a/public/vgui_controls/MessageMap.h +++ b/public/vgui_controls/MessageMap.h @@ -22,10 +22,6 @@ namespace vgui ////////////// MESSAGEMAP DEFINITIONS ////////////// -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - #ifndef ARRAYSIZE #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) #endif