From: "gaoliming" <gaoliming@byosoft.com.cn>
To: "'Michael D Kinney'" <michael.d.kinney@intel.com>,
<devel@edk2.groups.io>
Cc: "'Zhiguang Liu'" <zhiguang.liu@intel.com>
Subject: 回复: [Patch V2 1/7] MdePkg/Include: Update Base.h to improve C++ compatibility
Date: Tue, 8 Nov 2022 14:59:09 +0800 [thread overview]
Message-ID: <034501d8f33f$99bd0320$cd370960$@byosoft.com.cn> (raw)
In-Reply-To: <20221104202528.1157-2-michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> -----邮件原件-----
> 发件人: Michael D Kinney <michael.d.kinney@intel.com>
> 发送时间: 2022年11月5日 4:25
> 收件人: devel@edk2.groups.io
> 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Zhiguang Liu
> <zhiguang.liu@intel.com>
> 主题: [Patch V2 1/7] MdePkg/Include: Update Base.h to improve C++
> compatibility
>
> 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 <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
> 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
next prev parent reply other threads:[~2022-11-08 6:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 20:25 [Patch V2 0/7] Add GoogleTest to UnitTestFrameworkPkg Michael D Kinney
2022-11-04 20:25 ` [Patch V2 1/7] MdePkg/Include: Update Base.h to improve C++ compatibility Michael D Kinney
2022-11-08 6:59 ` gaoliming [this message]
2022-11-04 20:25 ` [Patch V2 2/7] MdePkg/Include/Library: Undefine _ASSERT() if already defined Michael D Kinney
2022-11-08 6:59 ` 回复: " gaoliming
2022-11-04 20:25 ` [Patch V2 3/7] UnitTestFrameworkPkg: Add googletest submodule and GoogleTestLib Michael D Kinney
2022-11-08 7:47 ` 回复: [edk2-devel] " gaoliming
2022-11-08 23:03 ` Michael D Kinney
2022-11-04 20:25 ` [Patch V2 4/7] UnitTestFrameworkPkg/Library/CmockaLib: Enable symbol files Michael D Kinney
2022-11-04 20:25 ` [Patch V2 5/7] .pytool: Add googletest submodule to CISettings.py Michael D Kinney
2022-11-04 20:25 ` [Patch V2 6/7] BaseTools/Plugin/HostBaseUnitTestRunner: Enable gtest xml output Michael D Kinney
2022-11-04 20:25 ` [Patch V2 7/7] MdePkg/Test: Add port of BaseSafeIntLib unit tests to GoogleTest Michael D Kinney
2022-11-08 6:59 ` 回复: [edk2-devel] " gaoliming
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='034501d8f33f$99bd0320$cd370960$@byosoft.com.cn' \
--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