Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building with ICU 75.1 or later #6486

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kou
Copy link
Contributor

@kou kou commented Mar 27, 2025

Pull Request Checklist

Please leverage this checklist as a reminder to address commonly occurring feedback when submitting a pull request to make sure your PR can be reviewed quickly:

See the detailed list in the contributing guide.

  • C++ Guidelines
  • Doxygen docs: Not needed
  • Unit tests: Not needed
  • No unwanted commits/changes
  • Descriptive title/description
    • PR is single purpose
    • Related issue listed: Should I create an issue for this?
  • Comments in source
  • No typos
  • Update changelog
  • Not work-in-progress
  • External references or docs updated: Not needed
  • Self review of PR done
  • Any breaking changes?: No

We use ICU via libxml2 implicitly. ICU 75.1 or later require C++17 for its C++ API:

https://github.com/unicode-org/icu/releases/tag/release-75-1

C++ code now requires C++17

But we use C++17. So #include <libxml/xmlreader.h> with ICU 75.1 or later causes an error:

[1/177] Building CXX object sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
FAILED: sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
/bin/c++ -DAZ_RTTI -DBUILD_CURL_HTTP_TRANSPORT_ADAPTER -D_azure_BUILDING_SDK
-Isdk/storage/azure-storage-common/inc -Isdk/core/azure-core/inc
-isystem /usr/include/libxml2 -g -std=gnu++14 -fno-operator-names
-Wold-style-cast -Wall -Wextra -pedantic -Werror -MD
-MT sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
-MF sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o.d
-o sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
-c sdk/storage/azure-storage-common/src/xml_wrapper.cpp
In file included from /usr/include/unicode/uenum.h:25,
                 from /usr/include/unicode/ucnv.h:52,
                 from /usr/include/libxml2/libxml/encoding.h:31,
                 from /usr/include/libxml2/libxml/parser.h:812,
                 from /usr/include/libxml2/libxml/globals.h:18,
                 from /usr/include/libxml2/libxml/threads.h:35,
                 from /usr/include/libxml2/libxml/xmlmemory.h:218,
                 from /usr/include/libxml2/libxml/tree.h:1307,
                 from /usr/include/libxml2/libxml/xmlreader.h:14,
                 from sdk/storage/azure-storage-common/src/xml_wrapper.cpp:23:
/usr/include/unicode/localpointer.h:561:26: error: 'auto' parameter not permitted in this context
  561 | template <typename Type, auto closeFunction>
      |                          ^~~~
/usr/include/unicode/localpointer.h:573:76: error: template argument 2 is invalid
  573 |     explicit LocalOpenPointer(std::unique_ptr<Type, decltype(closeFunction)> &&p)
      |                                                                            ^
/usr/include/unicode/localpointer.h:583:78: error: template argument 2 is invalid
  583 |     LocalOpenPointer &operator=(std::unique_ptr<Type, decltype(closeFunction)> &&p) {
      |                                                                              ^
/usr/include/unicode/localpointer.h:599:59: error: template argument 2 is invalid
  599 |     operator std::unique_ptr<Type, decltype(closeFunction)> () && {
      |                                                           ^
/usr/include/unicode/uenum.h:69:1: note: invalid template non-type parameter
   69 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUEnumerationPointer, UEnumeration, uenum_close);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/unicode/ucnv.h:597:1: note: invalid template non-type parameter
  597 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~

We don't need ICU C++ API. So we can avoid this error by disabling ICU C++ API by defining U_SHOW_CPLUSPLUS_API as 0.

@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files) Tables labels Mar 27, 2025
Copy link

Thank you for your contribution @kou! We will review the pull request and get back to you soon.

Copy link
Member

@antkmsft antkmsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @kou! Looks great to me. Let's, just in case, hear from the code owners - @gearama and @microzchang / @Jinming-Hu .

We use ICU via libxml2 implicitly. ICU 75.1 or later require C++17 for
its C++ API:

https://github.com/unicode-org/icu/releases/tag/release-75-1

> C++ code now requires C++17

But we use C++17. So `#include <libxml/xmlreader.h>` with ICU 75.1 or
later causes an error:

    [1/177] Building CXX object sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
    FAILED: sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
    /bin/c++ -DAZ_RTTI -DBUILD_CURL_HTTP_TRANSPORT_ADAPTER -D_azure_BUILDING_SDK
    -Isdk/storage/azure-storage-common/inc -Isdk/core/azure-core/inc
    -isystem /usr/include/libxml2 -g -std=gnu++14 -fno-operator-names
    -Wold-style-cast -Wall -Wextra -pedantic -Werror -MD
    -MT sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
    -MF sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o.d
    -o sdk/storage/azure-storage-common/CMakeFiles/azure-storage-common.dir/src/xml_wrapper.cpp.o
    -c sdk/storage/azure-storage-common/src/xml_wrapper.cpp
    In file included from /usr/include/unicode/uenum.h:25,
                     from /usr/include/unicode/ucnv.h:52,
                     from /usr/include/libxml2/libxml/encoding.h:31,
                     from /usr/include/libxml2/libxml/parser.h:812,
                     from /usr/include/libxml2/libxml/globals.h:18,
                     from /usr/include/libxml2/libxml/threads.h:35,
                     from /usr/include/libxml2/libxml/xmlmemory.h:218,
                     from /usr/include/libxml2/libxml/tree.h:1307,
                     from /usr/include/libxml2/libxml/xmlreader.h:14,
                     from sdk/storage/azure-storage-common/src/xml_wrapper.cpp:23:
    /usr/include/unicode/localpointer.h:561:26: error: 'auto' parameter not permitted in this context
      561 | template <typename Type, auto closeFunction>
          |                          ^~~~
    /usr/include/unicode/localpointer.h:573:76: error: template argument 2 is invalid
      573 |     explicit LocalOpenPointer(std::unique_ptr<Type, decltype(closeFunction)> &&p)
          |                                                                            ^
    /usr/include/unicode/localpointer.h:583:78: error: template argument 2 is invalid
      583 |     LocalOpenPointer &operator=(std::unique_ptr<Type, decltype(closeFunction)> &&p) {
          |                                                                              ^
    /usr/include/unicode/localpointer.h:599:59: error: template argument 2 is invalid
      599 |     operator std::unique_ptr<Type, decltype(closeFunction)> () && {
          |                                                           ^
    /usr/include/unicode/uenum.h:69:1: note: invalid template non-type parameter
       69 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUEnumerationPointer, UEnumeration, uenum_close);
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/unicode/ucnv.h:597:1: note: invalid template non-type parameter
      597 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close);
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~

We don't need ICU C++ API. So we can avoid this error by disabling ICU
C++ API by defining `U_SHOW_CPLUSPLUS_API` as `0`.
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

Co-authored-by: Anton Kolesnyk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files) Tables
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants