Re: [Patch] BaseTools: Fix PcdValueInit tool build issue with VS compiler x64


Sean
 

Reviewed-by: Sean Brogan <sean.brogan@...>

On 10/15/2020 4:20 AM, Bob Feng wrote:
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3001
When the 64-bit version of VS compiler is used, the generated
PcdValueInit tool will be failed to compile.
This patch is going to fix that issue.
Signed-off-by: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Sean Brogan <sean.brogan@...>
---
BaseTools/Source/C/Common/PcdValueCommon.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BaseTools/Source/C/Common/PcdValueCommon.h b/BaseTools/Source/C/Common/PcdValueCommon.h
index cfd3bb76e1..1652bd5430 100644
--- a/BaseTools/Source/C/Common/PcdValueCommon.h
+++ b/BaseTools/Source/C/Common/PcdValueCommon.h
@@ -12,11 +12,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Common/UefiBaseTypes.h>
#include <Common/UefiInternalFormRepresentation.h>
#define __FIELD_SIZE(TYPE, Field) (sizeof((TYPE *)0)->Field)
#define __ARRAY_ELEMENT_SIZE(TYPE, Field) (sizeof((TYPE *)0)->Field[0])
-#define __OFFSET_OF(TYPE, Field) ((UINT32) &(((TYPE *)0)->Field))
+#define __OFFSET_OF(TYPE, Field) ((UINT32)(size_t) &(((TYPE *)0)->Field))
#define __FLEXIBLE_SIZE(Size, TYPE, Field, MaxIndex) if (__FIELD_SIZE(TYPE, Field) == 0) Size = MAX((__OFFSET_OF(TYPE, Field) + __ARRAY_ELEMENT_SIZE(TYPE, Field) * (MaxIndex)), Size)
#define __ARRAY_SIZE(Array) (sizeof(Array)/sizeof(Array[0]))
#if defined(_MSC_EXTENSIONS)
#define __STATIC_ASSERT static_assert

Join devel@edk2.groups.io to automatically receive all group messages.