From 5447a230701c156383fa6c6887d8f0babf0fd34d Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Thu, 12 Sep 2024 14:22:15 -0700 Subject: [PATCH] ICU-22876 add U_SHOW_CPLUSPLUS_HEADER_API for C++ header-only APIs --- icu4c/source/common/unicode/uset.h | 4 ++-- icu4c/source/common/unicode/utypes.h | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/icu4c/source/common/unicode/uset.h b/icu4c/source/common/unicode/uset.h index 7cf0565f485f..cca2b0278a80 100644 --- a/icu4c/source/common/unicode/uset.h +++ b/icu4c/source/common/unicode/uset.h @@ -1325,7 +1325,7 @@ U_CAPI UBool U_EXPORT2 uset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex, UChar32* pStart, UChar32* pEnd); -#if U_SHOW_CPLUSPLUS_API +#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API #ifndef U_HIDE_DRAFT_API namespace U_HEADER_ONLY_NAMESPACE { @@ -1893,6 +1893,6 @@ class USetElements { } // namespace U_HEADER_ONLY_NAMESPACE #endif // U_HIDE_DRAFT_API -#endif // U_SHOW_CPLUSPLUS_API +#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API #endif // __USET_H__ diff --git a/icu4c/source/common/unicode/utypes.h b/icu4c/source/common/unicode/utypes.h index f1a89770f1f7..ba27be222349 100644 --- a/icu4c/source/common/unicode/utypes.h +++ b/icu4c/source/common/unicode/utypes.h @@ -54,22 +54,37 @@ * integer and other types. */ +/** @{ API visibility control */ /** * \def U_SHOW_CPLUSPLUS_API + * When defined to 1 (=default) and compiled with a C++ compiler, both C and C++ APIs are visible. + * Otherwise, only C APIs are visible; this is for C++ users who want to + * restrict their usage to binary stable C APIs exported by ICU DLLs. + * @internal + */ +/** + * \def U_SHOW_CPLUSPLUS_HEADER_API + * When defined to 1 (=default) and compiled with a C++ compiler, C++ header-only APIs are visible. + * This is for C++ users who restrict their usage to binary stable C APIs exported by ICU DLLs + * (U_SHOW_CPLUSPLUS_API=0) + * but who still want to use C++ header-only APIs which do not rely on ICU DLL exports. * @internal */ #ifdef __cplusplus # ifndef U_SHOW_CPLUSPLUS_API # define U_SHOW_CPLUSPLUS_API 1 # endif +# ifndef U_SHOW_CPLUSPLUS_HEADER_API +# define U_SHOW_CPLUSPLUS_HEADER_API 1 +# endif #else # undef U_SHOW_CPLUSPLUS_API # define U_SHOW_CPLUSPLUS_API 0 +# undef U_SHOW_CPLUSPLUS_HEADER_API +# define U_SHOW_CPLUSPLUS_HEADER_API 0 #endif -/** @{ API visibility control */ - /** * \def U_HIDE_DRAFT_API * Define this to 1 to request that draft API be "hidden"