From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from DM6FTOPR00CU001.outbound.protection.outlook.com (DM6FTOPR00CU001.outbound.protection.outlook.com [52.101.61.23]) by mx.groups.io with SMTP id smtpd.web11.4327.1684958866582142607 for ; Wed, 24 May 2023 13:07:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=EwVMSHE8; spf=pass (domain: microsoft.com, ip: 52.101.61.23, mailfrom: aaronpop@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FzrKQBWcC5GKnO9Od9J6Da2uBZP9Li9fPuOlrrdudLUslKLOF6r1Mmff7Igtiz5PP7AysO/h7oy5y1vOSracZMQeTNA6pWOwAAenIwiiJucB1LHJ4b4erjgmMhRkcHhQ3hEl3jpMchd70Of+yZvCcOyzUsOWwJEktJerq7NllBuZASt3g3TmipkLricK4idmhZmwdAFgJxYFTzreYEskGY+GnHQ3kIYOOAMCrFr1tG/GdjLc3NfUGpu5QQmd/3bbeOgUFyvwnQpxsz63dH6HqcX9QnpyGizzdTFehyWXgozJ97rDV86Nb7DYxcET/VdwQU5+nsQh3dOPnB/A6/iESA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pqk1L//p/cZInFTyocz5AeomaYyoPOg7+kFDP0V7760=; b=Xn3PRrrKDf2zuLW41WJEzFaCPs45BNFKRGedPOOa1UuhRe07NsBAQoz1EKOwyDuQ9XZvBy6OriYzAKkkcaThZDmsXPLbsiSKEE+IamVagcMSpct1OPHSkOmt2TlIjElx970WqevFRJJjjsGDE/UPJOR/5jCOTMVaPGnhzTgKXHfuEEh1oIz+TmmPv6PDctY2ivs5Djs2TliBRuG6sd2fVPJZAcwfQB21aXtOuyc8yirJYfo/vYhCi2AiZUYgVl3zhtj7jeeu5Z63Yl9xX0UGW2X05OmY224nukd1SjUypvZ/4MJSyK2oE6roGtdbm5gpKp1JbPueNf5iRRGTuQFWXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pqk1L//p/cZInFTyocz5AeomaYyoPOg7+kFDP0V7760=; b=EwVMSHE83Y/T+x1VKv/xxj935uDBjbJg7ahaLRk+wnZNRHaPFblaI5N8Eh1XcBQHhC0/TXKDhS5nlcfZg/jwo69MwnAupJRBmRLKqD9VsEBrcrJQmUh4ANcBSlzQJOyKeTu/8prhwyX+bIsbNBAYWO6rVxpEMobVsWQw7boA6lY= Received: from MW4PR21MB1940.namprd21.prod.outlook.com (2603:10b6:303:72::13) by SA0PR21MB3036.namprd21.prod.outlook.com (2603:10b6:806:153::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.13; Wed, 24 May 2023 20:07:42 +0000 Received: from MW4PR21MB1940.namprd21.prod.outlook.com ([fe80::a611:2a39:d0ee:ac6f]) by MW4PR21MB1940.namprd21.prod.outlook.com ([fe80::a611:2a39:d0ee:ac6f%7]) with mapi id 15.20.6455.004; Wed, 24 May 2023 20:07:42 +0000 From: "Aaron Pop" To: "Kinney, Michael D" , "devel@edk2.groups.io" Subject: Re: GoogleTest Compatibility with MdePkg's IndustyStandard header files Thread-Topic: GoogleTest Compatibility with MdePkg's IndustyStandard header files Thread-Index: AdmNCFzONb90exfORZ2x+UzGvNjL+wBauAkQAAHr8iA= Date: Wed, 24 May 2023 20:07:42 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=6ca6b3d0-a1a7-4645-a98a-43f873bd8465;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2023-05-22T23:40:24Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR21MB1940:EE_|SA0PR21MB3036:EE_ x-ms-office365-filtering-correlation-id: 961e6326-b81b-40a8-a855-08db5c92886d x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: h8u2K2U1L1P8TnI4R4pAU/K22ZUfubmFaSYRu32C9eEHKQzR+8BflyTS6HnLQi8eUJ7521VJ3o9f26xFLJVWz+tsme0GWv7+X+USKmYPG7aA4oSzse+sRXJD5StnyWSLhFZeNnCzXrrt8IR5vNY6yUdKYm3zyBjPSu4kTaSzf8v5BugZsXAUltIf+TgCuz77YI3tZk2wxdHk3gXdRWkjkxohpMu4EWCOKhtOiCbUmURpIbSXaiYQlHHuVESYjDNcXoQc1guh7ypvDeLlidpvwhWRHuyy/+DbFIxKPYXSZ53W3UstxlveQD7hzkHPOEBZwHNmKY7OuWbz9CHh1emL6OR6LdBBCvAwkUay4jt/hbgvPeqeEbhU58CxnX15gV5W14prM0tVfj9tx1uicalZqbMZZmdQQgUzmMtLo2uNYafUJ9XV8KZTqUd6OkRMt/cwFBXesuM6opyDIoc6wSo2By+uDR3o5aaywP5fH97jslsl5Ov+r/kuB9S6yrcROC+9orjPD+/7HKt3FNbEjpAHypme/W/koJPwEYid3DMuQsdbUEPB3d/keKoaxXP8vDvF95ov/4QHV0YHYRw+G5Mtat/N8pIheo3Twmy9S6jDGYaYUSz3EdhdvpBjOfZrrBRP0VWle/3k4qpbMQrBlHtY8AtZ54vCbaZxRdShzrVVCrA= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR21MB1940.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(346002)(376002)(136003)(396003)(451199021)(110136005)(66446008)(10290500003)(64756008)(66946007)(66556008)(66476007)(76116006)(8936002)(8676002)(9326002)(5660300002)(52536014)(26005)(7696005)(6506007)(53546011)(9686003)(478600001)(71200400001)(41300700001)(316002)(786003)(2906002)(186003)(8990500004)(82950400001)(82960400001)(122000001)(55016003)(33656002)(38070700005)(86362001)(38100700002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ekv5KRh/A/KBkNfo5uuBohmgaJT6eNIFqm0+sGa8PHaRTHoHjh9IJZdZcDyR?= =?us-ascii?Q?SKetS0mDbC7x5HxChpSJwXkA6siGo/03cmteO14LUiA/B+2UxAoLn25cW2f+?= =?us-ascii?Q?+w/Q3hlAsWhfgREoeu3kLz4dwtF6BOfUJ0jVUMvUDs9zQ3VXC07/ohvEYPY9?= =?us-ascii?Q?rBitH5K/rLgGYG5mUsyWZWm2QRkB+8muDCRLd5SOwD6iF/dXIOmyjJNIqu0F?= =?us-ascii?Q?kCHxSCWnkoJ7o6Klk81miK2o6t6wiGp7Q14g0X/JpStTC0iCA/R738aWuNOB?= =?us-ascii?Q?VvKX2FUyEHnsLgpPp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ascii?Q?WbWJs/O1bApyaRCbnedYvp88YsIgInNLRw6YcSA1BuR9qWtUJ79eGemh+Sqe?= =?us-ascii?Q?oKsZ5DIAUai4gj/HVM2oj5glBXZFAN1mDE62UeCC/cG7SLPr16Kym5UUKbGs?= =?us-ascii?Q?pcosgBmd7QR/IJ1VG76rlYDYbTPvRmOStQb0X+VFfEiYJ9FScHfry4yD1tSF?= =?us-ascii?Q?ck09hGMhi7/En3b8k/9qFfzv1ptHc6x968pix/aFKIl8wFUuRBU8JOudn5hh?= =?us-ascii?Q?E+RFfYvKMmfk/GcsBebZ1KfNU9we7soty162n33tjmUOst0clo1H983Ei2sQ?= =?us-ascii?Q?PeuXVpEuB0LaVKqzKCjQf1A5fyRYobX6GXpS?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR21MB1940.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 961e6326-b81b-40a8-a855-08db5c92886d X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2023 20:07:42.6346 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dPGH01XD1zDfK1ymfIvLufiYy+JWWFs1wQdWFgmcQk+pudf3uBVhcetfjPVAalTO9sDm044gXPZdMx7ZBNs7iA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR21MB3036 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MW4PR21MB1940271C4ADE942E2FD800FCDD41AMW4PR21MB1940namp_" --_000_MW4PR21MB1940271C4ADE942E2FD800FCDD41AMW4PR21MB1940namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Mike, What you suggested does work for MSVC, but it is failing with GCC. It sems = that GCC is very strict about operator names. Relevant errors below: error: "xor" cannot be used as a macro name as it is an operator in C++ #define xor XOR ^~~ error: "xor" cannot be used as a macro name as it is an operator in C++ #undef xor MdePkg/Include/IndustryStandard/Tpm20.h:1250:21: error: expected unqualifie= d-id before 'xor' token TPMI_ALG_HASH xor; ^~~ MdePkg/Include/IndustryStandard/Tpm20.h:1323:20: error: expected unqualifie= d-id before 'xor' token TPMS_SCHEME_XOR xor; ^~~ Aaron From: Kinney, Michael D Sent: Wednesday, May 24, 2023 12:49 PM To: Aaron Pop ; devel@edk2.groups.io Cc: Kinney, Michael D Subject: [EXTERNAL] RE: GoogleTest Compatibility with MdePkg's IndustyStand= ard header files Hi Aaron, Don't know if this will completely resolve your issues, but if you add some= preprocessor statements around the problematic includes in your unit test = CPP file, you may be able to get it to build. For example, I added the highlighted lines to MdePkg\Test\GoogleTest\Librar= y\BaseSafeIntLib\TestBaseSafeIntLib.cpp and I can get that unit test to bui= ld. Without the #define/#undef lines it fails in the way you describe. #include extern "C" { #include #include #define operator operator_ #define xor xor_ #include #include #undef operator #undef xor } Mike From: Aaron Pop > Sent: Monday, May 22, 2023 5:41 PM To: devel@edk2.groups.io Cc: Kinney, Michael D > Subject: GoogleTest Compatibility with MdePkg's IndustyStandard header file= s Google Test, and CPP, has more keywords C uses. Tpm12.h and Tpm20.h have references to struct names that are `operator` and `xor`, both of whic= h trigger build errors because they conflict with CPP's keywords. Operator triggered a build error in MSVC. Xor only triggered a build error = under GCC, MSVC did not have a problem with it. The work arounds suggested in the call, (using defines to get around the co= nflict) worked for operator, but did not work for xor with gcc. Tpm12.h: TPM_PERMANENT_FLAGS BOOLEAN operator; Tpm20.h: TPMU_SCHEME_KEYEDHASH TPMS_SCHEME_XOR xor; TPMU_SYM_KEY_BITS TPMI_ALG_HASH xor; What is the suggested method of trying to make existing header files compat= ible with google test? Thanks, Aaron --_000_MW4PR21MB1940271C4ADE942E2FD800FCDD41AMW4PR21MB1940namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Mike,

 

What you suggested does work for MSVC, but it is fai= ling with GCC. It sems that GCC is very strict about operator names.

 

Relevant errors below:

 

error: "xor" cannot be used as a macro nam= e as it is an operator in C++

#define xor       XOR<= o:p>

         &nb= sp;     ^~~

error: "xor" cannot be used as a macro nam= e as it is an operator in C++

#undef xor

MdePkg/Include/IndustryStandard/Tpm20.h:1250:21: err= or: expected unqualified-id before ‘xor’ token

TPMI_ALG_HASH     xor;

        &nbs= p;             =             &nb= sp; ^~~

MdePkg/Include/IndustryStandard/Tpm20.h:1323:20: err= or: expected unqualified-id before ‘xor’ token

TPMS_SCHEME_XOR  xor;

        &nbs= p;             =             &nb= sp;    ^~~

 

 

Aaron

 

From: Kinney, Michael D <michael.d.kinne= y@intel.com>
Sent: Wednesday, May 24, 2023 12:49 PM
To: Aaron Pop <aaronpop@microsoft.com>; devel@edk2.groups.io Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [EXTERNAL] RE: GoogleTest Compatibility with MdePkg's Indus= tyStandard header files

 

Hi Aaron,

 

Don’t know if this will completely resolve you= r issues, but if you add some preprocessor statements around the problemati= c includes in your unit test CPP file, you may be able to get it to build.<= o:p>

 

For example, I added the highlighted lines to MdePkg= \Test\GoogleTest\Library\BaseSafeIntLib\TestBaseSafeIntLib.cpp and I can ge= t that unit test to build.  Without the #define/#undef lines it fails = in the way you describe.

 

#include <gtest/gtest.h>

extern "C" {

  #include <Base.h>

  #include <Library/SafeIntLib.h>

 

#define operator operator_

#define xor xor_

 

  #include <IndustryStandard/Tpm20.h><= /p>

  #include <IndustryStandard/Tpm12.h>

 

#undef operator

#undef xor

}

 

Mike

 

 

From: Aaron Pop <aaronpop@microsoft.com>
Sent: Monday, May 22, 2023 5:41 PM
To: devel@edk2.groups.io=
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: GoogleTest Compatibility with MdePkg's IndustyStandard head= er files

 

Google Test, and CPP, has more keywords  C uses= .

 

Tpm12.h and Tpm20.h

have references to struct names that are `operator` = and `xor`, both of which trigger build errors because they conflict with CP= P’s keywords.

 

Operator triggered a build error in MSVC. Xor only t= riggered a build error under GCC, MSVC did not have a problem with it.

 

The work arounds suggested in the call, (using defin= es to get around the conflict) worked for operator, but did not work for xo= r with gcc. 

 

 

Tpm12.h:

TPM_PERMANENT_FLAGS

  BOOLEAN      &n= bsp;            = ;        operator;

 

 

Tpm20.h:

TPMU_SCHEME_KEYEDHASH

  TPMS_SCHEME_XO= R  xor;

TPMU_SYM_KEY_BITS

  TPMI_ALG_HASH     xor;

 

 

What is the suggested method of trying to make exist= ing header files compatible with google test?

 

Thanks,

Aaron

--_000_MW4PR21MB1940271C4ADE942E2FD800FCDD41AMW4PR21MB1940namp_--