public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: "Pop, Aaron" <aaronpop@microsoft.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: GoogleTest Compatibility with MdePkg's IndustyStandard header files
Date: Wed, 24 May 2023 19:49:02 +0000	[thread overview]
Message-ID: <CO1PR11MB49299486BF651E9790AFDE34D2419@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MW4PR21MB19404B34FBE9C39AEE9C26B0DD40A@MW4PR21MB1940.namprd21.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]

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\Library\BaseSafeIntLib\TestBaseSafeIntLib.cpp and I can get 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>
  #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 header 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 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 conflict) 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 compatible with google test?

Thanks,
Aaron

[-- Attachment #2: Type: text/html, Size: 6281 bytes --]

  reply	other threads:[~2023-05-24 19:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23  0:40 GoogleTest Compatibility with MdePkg's IndustyStandard header files aaronpop
2023-05-24 19:49 ` Michael D Kinney [this message]
2023-05-24 20:07   ` Aaron Pop
2023-05-24 21:23     ` Michael D Kinney
2023-05-24 21:55       ` [edk2-devel] " Pedro Falcato
2023-05-25  0:23         ` Michael D Kinney
2023-05-25  9:44           ` Pedro Falcato
2023-05-25 17:06             ` Michael D Kinney
2023-05-25 17:43               ` Oliver Smith-Denny
2023-05-25 18:01                 ` Pedro Falcato
2023-05-25 18:22                   ` Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB49299486BF651E9790AFDE34D2419@CO1PR11MB4929.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox