ICU-22876 add U_SHOW_CPLUSPLUS_HEADER_API for C++ header-only APIs

This commit is contained in:
Markus Scherer 2024-09-12 14:22:15 -07:00
parent 33a788b353
commit 5447a23070
2 changed files with 19 additions and 4 deletions
icu4c/source/common/unicode

View file

@ -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 @@ private:
} // 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__

View file

@ -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"