ICU headers cannot be built within extern "C" scope

Description

For example:

Introduced by commit b7a3571b additional include of <memory> without guard.

Found by xmlsec build.

Reproduce:

1 2 3 extern "C" { #include <unicode/localpointer.h> }
1 2 3 4 5 6 7 8 9 In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/memory:84, from /tmp/icu/icu4c/source/common/unicode/localpointer.h:45, from a.cxx:4: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/backward/auto_ptr.h:325:3: error: template with C linkage template<typename _Tp, typename _Dp> ^~~~~~~~ a.cxx:3:1: note: ‘extern "C"’ linkage started here extern "C" { ^~~~~~~~~~

Applied for:

  • char16ptr.h:#include <cstddef>

  • localpointer.h:#include <memory>

  • std_string.h:#include <string>

  • unistr.h:#include <cstddef>

In time the following requirement was not strictly followed:

1 2 3 4 5 6 7 8 9 10 11 /** * \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). * * It also begins a versioned-ICU-namespace block. * @stable ICU 2.4 */

Status

Assignee

Jeff Genovy

Reporter

Alon Bar-Lev

Labels

None

Reviewer

None

Time Needed

None

Start date

None

Components

Fix versions

Priority

assess