Skip to content

Commit

Permalink
ICU-20530 Fix header issues based on test/hdrtst
Browse files Browse the repository at this point in the history
Remove explicit extern "C++" scope.

Remove C++ macros in C mode.

Fix issues detected by make -C test/hdrtst.

Run test/hdrtest during CI to detect future breakage.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
  • Loading branch information
alonbl authored and jefgen committed Apr 25, 2019
1 parent 693adf3 commit 0aa19c0
Show file tree
Hide file tree
Showing 6 changed files with 293 additions and 316 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,23 @@ matrix:
#
# Test both out-of-source and in-source builds. This one (gcc) for out-of-source,
# and linux clang (below) for in-source.
#
# Invokes test/hdrtst to check public headers compliance.

- name: "c: linux gcc"
language: cpp
compiler: gcc
env: PREFIX=/tmp/icu-prefix
before_script:
- mkdir build
- cd build
- ../icu4c/source/runConfigureICU --enable-debug --disable-release Linux
- ../icu4c/source/runConfigureICU --enable-debug --disable-release Linux --prefix="${PREFIX}"
- make -j2
script:
- make -j2 check
- ( cd ../icu4c/source/test/depstest && ./depstest.py ../../../../build/ )
- make install
- PATH="${PREFIX}/bin:$PATH" make -C test/hdrtst check

- name: "c: linux clang"
language: cpp
Expand Down
39 changes: 20 additions & 19 deletions icu4c/source/common/unicode/ucptrie.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,25 +216,6 @@ ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth,
U_CAPI void U_EXPORT2
ucptrie_close(UCPTrie *trie);

#if U_SHOW_CPLUSPLUS_API

U_NAMESPACE_BEGIN

/**
* \class LocalUCPTriePointer
* "Smart pointer" class, closes a UCPTrie via ucptrie_close().
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @draft ICU 63
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUCPTriePointer, UCPTrie, ucptrie_close);

U_NAMESPACE_END

#endif

/**
* Returns the trie type.
*
Expand Down Expand Up @@ -642,5 +623,25 @@ ucptrie_internalU8PrevIndex(const UCPTrie *trie, UChar32 c,
U_CDECL_END

#endif // U_IN_DOXYGEN

#if U_SHOW_CPLUSPLUS_API

U_NAMESPACE_BEGIN

/**
* \class LocalUCPTriePointer
* "Smart pointer" class, closes a UCPTrie via ucptrie_close().
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @draft ICU 63
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUCPTriePointer, UCPTrie, ucptrie_close);

U_NAMESPACE_END

#endif // U_SHOW_CPLUSPLUS_API

#endif // U_HIDE_DRAFT_API
#endif
38 changes: 19 additions & 19 deletions icu4c/source/common/unicode/udata.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,25 +264,6 @@ udata_openChoice(const char *path, const char *type, const char *name,
U_STABLE void U_EXPORT2
udata_close(UDataMemory *pData);

#if U_SHOW_CPLUSPLUS_API

U_NAMESPACE_BEGIN

/**
* \class LocalUDataMemoryPointer
* "Smart pointer" class, closes a UDataMemory via udata_close().
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @stable ICU 4.4
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close);

U_NAMESPACE_END

#endif

/**
* Get the pointer to the actual data inside the data memory.
* The data is read-only.
Expand Down Expand Up @@ -434,4 +415,23 @@ udata_setFileAccess(UDataFileAccess access, UErrorCode *status);

U_CDECL_END

#if U_SHOW_CPLUSPLUS_API

U_NAMESPACE_BEGIN

/**
* \class LocalUDataMemoryPointer
* "Smart pointer" class, closes a UDataMemory via udata_close().
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @stable ICU 4.4
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close);

U_NAMESPACE_END

#endif // U_SHOW_CPLUSPLUS_API

#endif
32 changes: 9 additions & 23 deletions icu4c/source/common/unicode/uversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,29 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];
/* C++ namespace if supported. Versioned unless versioning is disabled. */
/*===========================================================================*/

/* Define C++ namespace symbols. */
#ifdef __cplusplus

/**
* \def U_NAMESPACE_BEGIN
* This is used to begin a declaration of a public ICU C++ API.
* When not compiling for C++, it does nothing.
* When compiling for C++, it begins an extern "C++" linkage block (to protect
* against cases in which an external client includes ICU header files inside
* an extern "C" linkage block).
* This is used to begin a declaration of a public ICU C++ API within
* versioned-ICU-namespace block.
*
* It also begins a versioned-ICU-namespace block.
* @stable ICU 2.4
*/

/**
* \def U_NAMESPACE_END
* This is used to end a declaration of a public ICU C++ API.
* When not compiling for C++, it does nothing.
* When compiling for C++, it ends the extern "C++" block begun by
* U_NAMESPACE_BEGIN.
* It ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN.
*
* It also ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN.
* @stable ICU 2.4
*/

/**
* \def U_NAMESPACE_USE
* This is used to specify that the rest of the code uses the
* public ICU C++ API namespace.
* This is invoked by default; we recommend that you turn it off:
* See the "Recommended Build Options" section of the ICU4C readme
* (http://source.icu-project.org/repos/icu/icu/trunk/readme.html#RecBuild)
* @stable ICU 2.4
*/

Expand All @@ -105,8 +98,6 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];
* @stable ICU 2.4
*/

/* Define C++ namespace symbols. */
#ifdef __cplusplus
# if U_DISABLE_RENAMING
# define U_ICU_NAMESPACE icu
namespace U_ICU_NAMESPACE { }
Expand All @@ -116,8 +107,8 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];
namespace icu = U_ICU_NAMESPACE;
# endif

# define U_NAMESPACE_BEGIN extern "C++" { namespace U_ICU_NAMESPACE {
# define U_NAMESPACE_END } }
# define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE {
# define U_NAMESPACE_END }
# define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE;
# define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE::

Expand All @@ -133,12 +124,7 @@ typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];
# if U_USING_ICU_NAMESPACE
U_NAMESPACE_USE
# endif
#else
# define U_NAMESPACE_BEGIN
# define U_NAMESPACE_END
# define U_NAMESPACE_USE
# define U_NAMESPACE_QUALIFIER
#endif
#endif /* __cplusplus */

/*===========================================================================*/
/* General version helper functions. Definitions in putil.c */
Expand Down
1 change: 1 addition & 0 deletions icu4c/source/i18n/unicode/reldatefmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class SharedPluralRules;
class SharedBreakIterator;
class NumberFormat;
class UnicodeString;
class FormattedRelativeDateTime;
class FormattedRelativeDateTimeData;

#ifndef U_HIDE_DRAFT_API
Expand Down
Loading

0 comments on commit 0aa19c0

Please sign in to comment.