From: Don Date: Tue, 18 Sep 2018 16:17:05 +0000 (-0700) Subject: ICU-20135 Use __has_declspec_attribute (#113) X-Git-Tag: release-63-rc~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc5bf22a0cfe2d8ad36eb848f2f3c44b5dc00bc6;p=icu ICU-20135 Use __has_declspec_attribute (#113) > Clang comes with __has_declspec_attribute to detect whether the name of an attribute is implemented as a MS style __declspec. > This adds __has_declspect_attribute to the list of clang compatibility macros and then uses that check to determine if __declspec(dllimport) and __declspec(dllexport) can be used. --- diff --git a/icu4c/source/common/unicode/platform.h b/icu4c/source/common/unicode/platform.h index 4c1603554fb..a3623f5da6a 100644 --- a/icu4c/source/common/unicode/platform.h +++ b/icu4c/source/common/unicode/platform.h @@ -420,6 +420,9 @@ #ifndef __has_cpp_attribute # define __has_cpp_attribute(x) 0 #endif +#ifndef __has_declspec_attribute +# define __has_declspec_attribute(x) 0 +#endif #ifndef __has_builtin # define __has_builtin(x) 0 #endif @@ -783,6 +786,8 @@ namespace std { /* Use the predefined value. */ #elif defined(U_STATIC_IMPLEMENTATION) # define U_EXPORT +#elif defined(_MSC_VER) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)) +# define U_EXPORT __declspec(dllexport) #elif defined(__GNUC__) # define U_EXPORT __attribute__((visibility("default"))) #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ @@ -790,8 +795,6 @@ namespace std { # define U_EXPORT __global /*#elif defined(__HP_aCC) || defined(__HP_cc) # define U_EXPORT __declspec(dllexport)*/ -#elif defined(_MSC_VER) -# define U_EXPORT __declspec(dllexport) #else # define U_EXPORT #endif @@ -807,7 +810,7 @@ namespace std { #ifdef U_IMPORT /* Use the predefined value. */ -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)) /* Windows needs to export/import data. */ # define U_IMPORT __declspec(dllimport) #else