MdePkg/Include/Library: Undefine _ASSERT() if already defined

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

When unit testing is enabled, make sure _ASSERT() is not already
defined by the host environment before defining _ASSERT().  This
avoids conflicts with VS20xx builds of GoogleTest based unit tests.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael D Kinney 2022-10-11 12:03:48 -07:00 committed by mergify[bot]
parent 933b4c333c
commit c1b073a9dc
1 changed files with 3 additions and 0 deletions

View File

@ -337,6 +337,9 @@ UnitTestDebugAssert (
IN CONST CHAR8 *Description IN CONST CHAR8 *Description
); );
#if defined (_ASSERT)
#undef _ASSERT
#endif
#if defined (__clang__) && defined (__FILE_NAME__) #if defined (__clang__) && defined (__FILE_NAME__)
#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
#else #else