From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mx.groups.io with SMTP id smtpd.web11.18561.1685037692325157380 for ; Thu, 25 May 2023 11:01:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20221208 header.b=dT/Fz9Ki; spf=pass (domain: gmail.com, ip: 209.85.214.180, mailfrom: pedro.falcato@gmail.com) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1ae452c2777so77015ad.0 for ; Thu, 25 May 2023 11:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685037692; x=1687629692; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BNI4Kvqo3rPrRnvznK2KSMUXYJiFcMLxwRGez9kXDSg=; b=dT/Fz9KiMNAB7WdEF+HCtlgzQZWkN1DLDjv1X9+Y09m+cO4bV3wjOeM24bRPJ9yiwp 1wb7DBCMe3YIEYRB15F54nLWiEqngCHZstOTxfkad7d4Fm+xUy0MCCcnNijLm6l9M2TV yRJELZOP0s2+qfeCYjBdt8j/MsCQtbM1gKkH3MKRW0xp2dG/pIonxec7Eut3aOzJW0+s cEULHdyNJkRrOXrpGVAVSRj9KOWtyHNzZX1s2u1DbLQFvexXIAEqro4lszEcu3jwSsPK mge2uNjDTDDqFSa1oEEx2PG/H1jLMe7vE93OXis7SMzTZCG1iQ7ox66sqdSAQT0JjJMm rR5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685037692; x=1687629692; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BNI4Kvqo3rPrRnvznK2KSMUXYJiFcMLxwRGez9kXDSg=; b=HZ5A7dFk45cgTZEGSstNl4AKXiKn224ohfgVkdV0WGI9KY+XhYhc7ch07D4ynopxWT UO4OKFKQ7beBdnZJhTVHR2d3oGvd835o74+pTJKx3ErDDSSDXvBHMbdeCDVk2UFT2CDV 0O9RGbtazS96nxQEO6RyMFCN4N6DhAExNg/Jqatkw5XY6vh0RGh+npuJH6UrnCPJNSNs 5Wmm5ElnA/Wx58tZGv7Jq/WAgI3vn4vGFJEEoOTtgrNXeFQ4BKjo7NXyMEJfCD6qizHx nIkscwfR2sm1Rmw82MgoWjNDib4oWL3w1ODlHMAKAIGqEwGvjLr8JkTC+P0joPgXN4Mn me2g== X-Gm-Message-State: AC+VfDwVWJF3UZdaOuLWeZGO6BENii8ZZVxJO/6n6MJGTVY9/khLaOgI YFk8Re4wisqVqpgoPwqxEwTIjjpqE4hYRcpRCCs= X-Google-Smtp-Source: ACHHUZ4kDUEDln2C0PsGPFeJiMGmb0ky8d1p/jP9KqzV6nIPE1iedfFp7V6vYjpjTE4T1yzEAWqnms1usLd/i0CO1Ms= X-Received: by 2002:a17:902:ea0d:b0:1ad:b5ed:e951 with SMTP id s13-20020a170902ea0d00b001adb5ede951mr2765813plg.13.1685037691603; Thu, 25 May 2023 11:01:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Pedro Falcato" Date: Thu, 25 May 2023 19:01:20 +0100 Message-ID: Subject: Re: [edk2-devel] GoogleTest Compatibility with MdePkg's IndustyStandard header files To: Oliver Smith-Denny Cc: devel@edk2.groups.io, michael.d.kinney@intel.com, "Pop, Aaron" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 25, 2023 at 6:43=E2=80=AFPM Oliver Smith-Denny wrote: > > Hi Mike, > > Thanks for looking for solutions here. This one feels like > quite a back bend, I'm imagining reading code and coming > across TpmStruct.CPLUSPLUS_OPERATOR_KEYWORD and having to > dig around quite a lot to see what goodness is going > on. Because we would have to update the C files, too, right, No, the idea is that current C code can use the already-existing-and-standard .operator and .xor, and C++ can use .operator_ and .xor_ (or the macros, although please no?). But my idea was to leave this as a Tpm.h hack, not in Base.h (new headers and structs should take C++ into account). > depending on the test (there exist tests that want to test > static functions and so include the C file in the unit test > file). Perhaps that is an anti-pattern and googletest has This is a hacky solution. Either write things in C++, or don't include .c in .cpp. C code is not C++ code. There's a lot of C code that does not and should not compile in C++. So: 1) Write the actual functionality code in C++. This is not yet supported in EDK2 (I'm a proponent of this) 2) Don't make the functions you're testing static, or make them conditionally static on something Note: Adding proper, actual C++ code to EDK2 requires some care, but could result in actual good changes. I don't know how well this would be received by the community though. > But, that being said, this is an issue we face, so perhaps > it would be simpler to just rename the members to not conflict > with the C++ keywords, as previously suggested, even though > this may differ from the spec, but it would more align with > EDKII's conventions (shouty case) where the C++ keywords seem > to be lowercase. With the below patch, we would already be I think breaking all sorts of users for this sort of "silly" problems is not a good option here. There's no actual need for this ATM, apart from "We want to test this silly code in this new Google Test library that just appeared upstream". But these are just my 2c of course. --=20 Pedro