From: Shane Carr Date: Fri, 29 Sep 2017 00:16:08 +0000 (+0000) Subject: ICU-13383 Adding macro UPRV_SUPPRESS_DLL_INTERFACE_WARNING to suppress Visual C+... X-Git-Tag: release-60-rc~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=680ba3ce21de0a3e75dda9456e249643e17e1460;p=icu ICU-13383 Adding macro UPRV_SUPPRESS_DLL_INTERFACE_WARNING to suppress Visual C++ compiler warnings. X-SVN-Rev: 40512 --- diff --git a/icu4c/source/common/unicode/platform.h b/icu4c/source/common/unicode/platform.h index e1a7bdbc745..383c408adca 100644 --- a/icu4c/source/common/unicode/platform.h +++ b/icu4c/source/common/unicode/platform.h @@ -525,6 +525,20 @@ namespace std { # define U_FALLTHROUGH #endif +/** +* \def UPRV_SUPPRESS_DLL_INTERFACE_WARNING +* Add a pragma for suppressing warning 4251: +* "class X needs to have dll-interface to be used by clients of class Y" +* This warning is noisy when private member fields are at play. +* Macro is empty except on Visual C++. +* @internal +*/ +#if defined(_MSC_VER) +# define UPRV_SUPPRESS_DLL_INTERFACE_WARNING __pragma(warning(suppress: 4251)) +#else +# define UPRV_SUPPRESS_DLL_INTERFACE_WARNING +#endif + /** @} */ /*===========================================================================*/ diff --git a/icu4c/source/i18n/number_decimfmtprops.h b/icu4c/source/i18n/number_decimfmtprops.h index 3815b250f25..da4b34f7f73 100644 --- a/icu4c/source/i18n/number_decimfmtprops.h +++ b/icu4c/source/i18n/number_decimfmtprops.h @@ -20,7 +20,7 @@ namespace impl { // TODO: Figure out a nicer way to deal with CurrencyPluralInfo. // Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties struct U_I18N_API CurrencyPluralInfoWrapper { -#pragma warning(suppress: 4251) // LocalPointer is defined in a header file; why does Visual Studio complain? + UPRV_SUPPRESS_DLL_INTERFACE_WARNING // LocalPointer is defined in a header file; why does Visual Studio complain? LocalPointer fPtr; CurrencyPluralInfoWrapper() {} diff --git a/icu4c/source/i18n/number_patternmodifier.h b/icu4c/source/i18n/number_patternmodifier.h index 8ea1e24d9a8..0beeffe91f9 100644 --- a/icu4c/source/i18n/number_patternmodifier.h +++ b/icu4c/source/i18n/number_patternmodifier.h @@ -31,7 +31,7 @@ class U_I18N_API ImmutablePatternModifier : public MicroPropsGenerator { private: ImmutablePatternModifier(ParameterizedModifier *pm, const PluralRules *rules, const MicroPropsGenerator *parent); -#pragma warning(suppress: 4251) // Member is private and does not need to be exported + UPRV_SUPPRESS_DLL_INTERFACE_WARNING // Member is private and does not need to be exported const LocalPointer pm; const PluralRules *rules; const MicroPropsGenerator *parent; diff --git a/icu4c/source/i18n/number_patternstring.h b/icu4c/source/i18n/number_patternstring.h index 43b03b426a5..81b81763570 100644 --- a/icu4c/source/i18n/number_patternstring.h +++ b/icu4c/source/i18n/number_patternstring.h @@ -96,7 +96,7 @@ struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider, public UMemor // This method is here as a shell for Java compatibility. inline void toParseException(const char16_t *message) { (void)message; } } -#pragma warning(suppress: 4251) // Member is private and does not need to be exported + UPRV_SUPPRESS_DLL_INTERFACE_WARNING // Member is private and does not need to be exported state; // NOTE: In Java, these are written as pure functions. diff --git a/icu4c/source/i18n/unicode/numberformatter.h b/icu4c/source/i18n/unicode/numberformatter.h index 2127f9dd48c..60f25ac5c50 100644 --- a/icu4c/source/i18n/unicode/numberformatter.h +++ b/icu4c/source/i18n/unicode/numberformatter.h @@ -1818,9 +1818,9 @@ class U_I18N_API LocalizedNumberFormatter ~LocalizedNumberFormatter(); private: -#pragma warning(suppress: 4251) // Member is private and does not need to be exported + UPRV_SUPPRESS_DLL_INTERFACE_WARNING // Member is private and does not need to be exported std::atomic fCompiled{nullptr}; -#pragma warning(suppress: 4251) // Member is private and does not need to be exported + UPRV_SUPPRESS_DLL_INTERFACE_WARNING // Member is private and does not need to be exported std::atomic fCallCount{0}; LocalizedNumberFormatter() = default;