Opened 4 years ago

Closed 20 months ago

#60325 closed defect (fixed)

icu 65.1: platform.h has macro clash with cpprestsdk (and possibly other libraries)

Reported by: Lord-Kamina (Gregorio Litenstein) Owned by: catap (Kirill A. Korinsky)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc:
Port: icu

Description

I'll soon make a PR for this because it appears to be a simple fix; nonetheless, I figured it would be a good idea to make a ticket here also so we can track when it gets fixed upstream (I've already reported it at https://unicode-org.atlassian.net/browse/ICU-21064

In short, in ICU65.1, they introduced macros around Clang's __has_attribute features. In a few places they use those calls with dllexportand dllimportas parameters, which clashes with macro definitions in CppRestSdk. In my case, I noticed this compiling an app that uses both CppRestSdk and ICU, which failed with the following error:

In file included from /Users/Koji/performous/game/unicode.hh:6:
In file included from /opt/local/include/libxml2/unicode/tblcoll.h:65:
In file included from /opt/local/include/libxml2/unicode/utypes.h:38:
In file included from /opt/local/include/libxml2/unicode/umachine.h:46:
In file included from /opt/local/include/libxml2/unicode/ptypes.h:52:
/opt/local/include/libxml2/unicode/platform.h:818:29: error: too few arguments provided to function-like macro invocation
                            UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport))
                            ^
/opt/local/include/libxml2/unicode/platform.h:438:69: note: expanded from macro 'UPRV_HAS_DECLSPEC_ATTRIBUTE'
#   define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x)
                                                                    ^
/opt/local/include/libxml2/unicode/platform.h:843:29: error: too few arguments provided to function-like macro invocation
                            UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport))
                            ^
/opt/local/include/libxml2/unicode/platform.h:438:69: note: expanded from macro 'UPRV_HAS_DECLSPEC_ATTRIBUTE'
#   define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x)

I'm not entirely sure whose at fault here, ICU or CppRestSdk, but as per https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute, enclosing the attributes in double underscores will prevent the clash (I tested it, and the error went away, at least)

Change History (6)

comment:1 Changed 4 years ago by mf2k (Frank Schima)

Keywords: declspec clang dllimport dllexport cpprestsdk removed

comment:2 Changed 4 years ago by Lord-Kamina (Gregorio Litenstein)

In 65ebd8e5ecad21339db4efe23db76022362c023c/macports-ports (master):

icu: Fix possibly-conflicting macro invocation

See: #60325

This is a potential bug introduced in icu65.1. I’ve already reported it upstream, but who knows when it’ll get fixed.

As of now, this was producing a conflict with at least CppRestSdk

comment:3 Changed 4 years ago by blair (Blair Zajac)

Can this be closed?

comment:4 Changed 3 years ago by kencu (Ken)

Owner: set to kencu
Status: newaccepted

comment:5 Changed 3 years ago by kencu (Ken)

Owner: kencu deleted
Status: acceptedassigned

comment:6 Changed 20 months ago by catap (Kirill A. Korinsky)

Owner: set to catap
Resolution: fixed
Status: assignedclosed

In 3aefb52514bc17fa2d334dd2032ba65514aef03e/macports-ports (master):

icu: update to 71.1

It contains massive revision bump of all ports which depends on icu.

I've also tested to build it with llvm-ar from clang-11 on macOS 10.6
and it works.

Closes: #59515
Closes: #60325
Closes: #64398

[skip ci]

Note: See TracTickets for help on using tickets.