Skip to content

Commit

Permalink
ICU-22876 add U_SHOW_CPLUSPLUS_HEADER_API for C++ header-only APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
markusicu committed Sep 12, 2024
1 parent 33a788b commit 5447a23
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions icu4c/source/common/unicode/uset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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__
19 changes: 17 additions & 2 deletions icu4c/source/common/unicode/utypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5447a23

Please sign in to comment.