ICU-13383 Adding macro UPRV_SUPPRESS_DLL_INTERFACE_WARNING to suppress Visual C+...
authorShane Carr <shane@unicode.org>
Fri, 29 Sep 2017 00:16:08 +0000 (00:16 +0000)
committerShane Carr <shane@unicode.org>
Fri, 29 Sep 2017 00:16:08 +0000 (00:16 +0000)
X-SVN-Rev: 40512

icu4c/source/common/unicode/platform.h
icu4c/source/i18n/number_decimfmtprops.h
icu4c/source/i18n/number_patternmodifier.h
icu4c/source/i18n/number_patternstring.h
icu4c/source/i18n/unicode/numberformatter.h

index e1a7bdbc745e7ef50b45c63e17806837a1da3c16..383c408adca3935af7a1ebc17851f38b3e54ae52 100644 (file)
@@ -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
+
 /** @} */
 
 /*===========================================================================*/
index 3815b250f25970c8b6b73b4d32c94508642ba34e..da4b34f7f7304285720200b1d8e08c8775dedc7d 100644 (file)
@@ -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<CurrencyPluralInfo> fPtr;
 
     CurrencyPluralInfoWrapper() {}
index 8ea1e24d9a875f3850af863992543cd087edf5e4..0beeffe91f95aae38de5689abf3f7535e086eaf3 100644 (file)
@@ -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<ParameterizedModifier> pm;
     const PluralRules *rules;
     const MicroPropsGenerator *parent;
index 43b03b426a5ce7ff22b3f8f5a2261b853ea49942..81b81763570120d3127586d0e569eb8641781a82 100644 (file)
@@ -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.
index 2127f9dd48c259a27fdf7e26cdb4628943d532be..60f25ac5c505c275c970a0ea73bde10666615112 100644 (file)
@@ -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<const impl::NumberFormatterImpl *> 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<uint32_t> fCallCount{0};
 
     LocalizedNumberFormatter() = default;