From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.21.1667949182063513285 for ; Tue, 08 Nov 2022 15:13:02 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=CdIaXy4o; spf=pass (domain: intel.com, ip: 134.134.136.24, 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=1667949182; x=1699485182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OA2CCvQPSOHjkPmK6pbi30W24FQhdGVTwzlxn0TYxio=; b=CdIaXy4oJ7hocC24vgiMJyf2fiB5tL0dYMunHE82GVDalfcKbtTC6UYn vmScIbolNn3VPsMU2rHEHAyE+1DzfGZks9+NJLxAAa9tciWp9OB4+WHXs w4yZB2AgJTqr8fhP94UJX0oo6tkK+4prbWYMFLbo/4/9ur6A6CCb2R6tw /Fy6oAkzpDcj/BQvndvD4XqPbXTbUVOcS3u+ARbsgT/RB/+eweGci4YMl MevqY0fPPk91eFp6Ant2kh+/I0K0OuV5Vwc3x4brbX7VmXm1sWQLgxvxk tVRG4N5hZVs2l6J3ciaH6D97trRsO+0YqYJMDZ6/H7znYaKYiO+Tng2aI A==; X-IronPort-AV: E=McAfee;i="6500,9779,10525"; a="311990217" X-IronPort-AV: E=Sophos;i="5.96,149,1665471600"; d="scan'208";a="311990217" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2022 15:13:00 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10525"; a="636512150" X-IronPort-AV: E=Sophos;i="5.96,149,1665471600"; d="scan'208";a="636512150" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.209.46.35]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2022 15:12:59 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Zhiguang Liu Subject: [Patch v3 1/7] MdePkg/Include: Update Base.h to improve C++ compatibility Date: Tue, 8 Nov 2022 15:12:46 -0800 Message-Id: <20221108231252.1864-2-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20221108231252.1864-1-michael.d.kinney@intel.com> References: <20221108231252.1864-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 Reviewed-by: Liming Gao --- 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