From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web09.5311.1575007919039592895 for ; Thu, 28 Nov 2019 22:11:59 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Nov 2019 22:11:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,256,1571727600"; d="scan'208";a="409542218" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 28 Nov 2019 22:11:58 -0800 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 28 Nov 2019 22:11:58 -0800 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 28 Nov 2019 22:11:58 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.200]) with mapi id 14.03.0439.000; Fri, 29 Nov 2019 14:11:56 +0800 From: "Liming Gao" To: Alex James , "devel@edk2.groups.io" CC: "Kinney, Michael D" Subject: Re: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain Thread-Topic: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain Thread-Index: AQHVpbCmSzy9A8DL+kyRFm9+9yIZa6ehq3qA Date: Fri, 29 Nov 2019 06:11:56 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E54A92F@SHSMSX104.ccr.corp.intel.com> References: <20191128055645.53053-1-theracermaster@gmail.com> In-Reply-To: <20191128055645.53053-1-theracermaster@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable BZ https://bugzilla.tianocore.org/show_bug.cgi?id=3D2393 is submitted to re= cord this issue.=20 This is the corner issue when STATIC_ASSERT and OFFSET_OF are used together= . So, I think we can fix it after stable tag 201911. Thanks Liming >-----Original Message----- >From: Alex James [mailto:theracermaster@gmail.com] >Sent: Thursday, November 28, 2019 1:57 PM >To: devel@edk2.groups.io >Cc: Kinney, Michael D ; Gao, Liming > >Subject: [PATCH v1] MdePkg: Use __builtin_offset with CLANGPDB toolchain > >CLANGPDB does not define __GNUC__, but it does define __clang__. Check >for the __clang__ preprocessor definition to use __builtin_offsetof to >implement the OFFSET_OF macro. > >Cc: Michael D Kinney >Cc: Liming Gao >Signed-off-by: Alex James >--- > MdePkg/Include/Base.h | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > >diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h >index 4680e64136..e0bcd0ae67 100644 >--- a/MdePkg/Include/Base.h >+++ b/MdePkg/Include/Base.h >@@ -781,11 +781,9 @@ typedef UINTN *BASE_LIST; > @return Offset, in bytes, of field. > > > > **/ > >-#ifdef __GNUC__ > >-#if __GNUC__ >=3D 4 > >+#if (defined(__GNUC__) && __GNUC__ >=3D 4) || defined(__clang__) > > #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field)) > > #endif > >-#endif > > > > #ifndef OFFSET_OF > > #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field)) > >-- >2.24.0