From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.2518.1667593537052236213 for ; Fri, 04 Nov 2022 13:25:37 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=H8FuTbes; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: michael.d.kinney@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667593537; x=1699129537; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6CFqCs5jiqagZc4jJgfYvQv3G/1rEVRSOvMhhwpfBKY=; b=H8FuTbessbGwUvw5N7qvAOXA1SR/g1JEIvI7uCD+aRKo368ir9DUh32Y BNkeuUbPwoxnPbGVSq4Bf3Ok0fRVTQosXZTrH71XphjQMl3TYpP/i2iKG +ou+1W9pGRLTGtjGaLYI0yexMOFTUGtumJaqD3QI371YtUN9VxVdnVtWB vv1twZD5XaWcVKvZhndPgcNoClVjYv8R9OHmlDTHK2QOQEjTFDT0KynV8 7QyLUUdy+4cSdg9thNnuUxojhbLSo/0NrgGEmt9L+gT9ETKVdHBxqsvlY x564J8ar15vYcOXPoPG0zz2D5uX1i8NBdkM4NC8q6W7H5MGR5EY+408uM Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="396363606" X-IronPort-AV: E=Sophos;i="5.96,138,1665471600"; d="scan'208";a="396363606" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2022 13:25:37 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="777839148" X-IronPort-AV: E=Sophos;i="5.96,138,1665471600"; d="scan'208";a="777839148" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.255.31]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2022 13:25:36 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Zhiguang Liu Subject: [Patch V2 1/7] MdePkg/Include: Update Base.h to improve C++ compatibility Date: Fri, 4 Nov 2022 13:25:22 -0700 Message-Id: <20221104202528.1157-2-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20221104202528.1157-1-michael.d.kinney@intel.com> References: <20221104202528.1157-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134 * Map NULL to nullptr or __null when c++ compiler is used. * Map STATIC_ASSERT to static_assert when a c++ compiler is used. * Typecast RETURN_SUCCESS to type RETURN_STATUS to match type used by all return error/warning status codes. C++ has stricter type checking and found this inconsistency. Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Michael D Kinney --- MdePkg/Include/Base.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index d19ddfe4bba7..d209e6de280a 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -309,7 +309,15 @@ struct _LIST_ENTRY { /// /// NULL pointer (VOID *) /// +#if defined (__cplusplus) + #if defined (_MSC_EXTENSIONS) +#define NULL nullptr + #else +#define NULL __null + #endif +#else #define NULL ((VOID *) 0) +#endif // // Null character @@ -760,7 +768,7 @@ typedef UINTN *BASE_LIST; **/ #ifdef MDE_CPU_EBC #define STATIC_ASSERT(Expression, Message) -#elif defined (_MSC_EXTENSIONS) +#elif defined (_MSC_EXTENSIONS) || defined (__cplusplus) #define STATIC_ASSERT static_assert #else #define STATIC_ASSERT _Static_assert @@ -959,7 +967,7 @@ typedef UINTN RETURN_STATUS; /// /// The operation completed successfully. /// -#define RETURN_SUCCESS 0 +#define RETURN_SUCCESS (RETURN_STATUS)(0) /// /// The image failed to load. -- 2.37.1.windows.1