[edk2-devel] GoogleTest Compatibility with MdePkg's IndustyStandard header files
Michael D Kinney
michael.d.kinney at intel.com
Wed May 24 19:49:02 UTC 2023
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 at microsoft.com>
Sent: Monday, May 22, 2023 5:41 PM
To: devel at edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney at 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105282): https://edk2.groups.io/g/devel/message/105282
Mute This Topic: https://groups.io/mt/99079638/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3943202/1813853/130120423/xyzzy [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20230524/7d83cf20/attachment-0001.htm>
More information about the edk2-devel-archive
mailing list