From: Shane Carr Date: Thu, 28 Sep 2017 22:53:31 +0000 (+0000) Subject: ICU-13177 Fixing Visual Studio build warnings in number formatting code. X-Git-Tag: release-60-rc~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8368d6da441d6ab75eb463062adb2d2902cc427;p=icu ICU-13177 Fixing Visual Studio build warnings in number formatting code. X-SVN-Rev: 40510 --- diff --git a/icu4c/source/i18n/number_affixutils.h b/icu4c/source/i18n/number_affixutils.h index 1e3c30d2719..db10f866c4a 100644 --- a/icu4c/source/i18n/number_affixutils.h +++ b/icu4c/source/i18n/number_affixutils.h @@ -44,7 +44,8 @@ struct AffixTag { {} }; -class SymbolProvider { +// Exported as U_I18N_API because it is a base class for other exported types +class U_I18N_API SymbolProvider { public: // TODO: Could this be more efficient if it returned by reference? virtual UnicodeString getSymbol(AffixPatternType type) const = 0; diff --git a/icu4c/source/i18n/number_decimfmtprops.h b/icu4c/source/i18n/number_decimfmtprops.h index 3afd0078de9..3815b250f25 100644 --- a/icu4c/source/i18n/number_decimfmtprops.h +++ b/icu4c/source/i18n/number_decimfmtprops.h @@ -10,6 +10,7 @@ #include "unicode/plurrule.h" #include "unicode/currpinf.h" #include "unicode/unum.h" +#include "unicode/localpointer.h" #include "number_types.h" U_NAMESPACE_BEGIN @@ -17,7 +18,9 @@ namespace number { namespace impl { // TODO: Figure out a nicer way to deal with CurrencyPluralInfo. -struct CurrencyPluralInfoWrapper { +// 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? LocalPointer fPtr; CurrencyPluralInfoWrapper() {} @@ -28,6 +31,7 @@ struct CurrencyPluralInfoWrapper { } }; +// Exported as U_I18N_API because it is needed for the unit test PatternStringTest struct U_I18N_API DecimalFormatProperties { public: diff --git a/icu4c/source/i18n/number_patternmodifier.h b/icu4c/source/i18n/number_patternmodifier.h index 45f9dc352ea..8ea1e24d9a8 100644 --- a/icu4c/source/i18n/number_patternmodifier.h +++ b/icu4c/source/i18n/number_patternmodifier.h @@ -16,21 +16,27 @@ U_NAMESPACE_BEGIN namespace number { namespace impl { +// Forward declaration +class MutablePatternModifier; + +// Exported as U_I18N_API because it is needed for the unit test PatternModifierTest class U_I18N_API ImmutablePatternModifier : public MicroPropsGenerator { public: - ImmutablePatternModifier(ParameterizedModifier *pm, const PluralRules *rules, - const MicroPropsGenerator *parent); - - ~ImmutablePatternModifier() override = default; + ~ImmutablePatternModifier() override = default; void processQuantity(DecimalQuantity &, MicroProps µs, UErrorCode &status) const override; void applyToMicros(MicroProps µs, DecimalQuantity &quantity) const; private: - const LocalPointer pm; + ImmutablePatternModifier(ParameterizedModifier *pm, const PluralRules *rules, const MicroPropsGenerator *parent); + +#pragma warning(suppress: 4251) // Member is private and does not need to be exported + const LocalPointer pm; const PluralRules *rules; const MicroPropsGenerator *parent; + + friend class MutablePatternModifier; }; /** diff --git a/icu4c/source/i18n/number_patternstring.h b/icu4c/source/i18n/number_patternstring.h index 03f08cdf341..43b03b426a5 100644 --- a/icu4c/source/i18n/number_patternstring.h +++ b/icu4c/source/i18n/number_patternstring.h @@ -25,7 +25,8 @@ struct Endpoints { int32_t end = 0; }; -struct ParsedSubpatternInfo { +// Exported as U_I18N_API because it is a public member field of exported ParsedPatternInfo +struct U_I18N_API ParsedSubpatternInfo { int64_t groupingSizes = 0x0000ffffffff0000L; int32_t integerLeadingHashSigns = 0; int32_t integerTrailingHashSigns = 0; @@ -52,7 +53,8 @@ struct ParsedSubpatternInfo { Endpoints paddingEndpoints; }; -struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider { +// Exported as U_I18N_API because it is needed for the unit test PatternStringTest +struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider, public UMemory { UnicodeString pattern; ParsedSubpatternInfo positive; ParsedSubpatternInfo negative; @@ -93,7 +95,9 @@ struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider { // TODO: We don't currently do anything with the message string. // This method is here as a shell for Java compatibility. inline void toParseException(const char16_t *message) { (void)message; } - } state; + } +#pragma warning(suppress: 4251) // Member is private and does not need to be exported + state; // NOTE: In Java, these are written as pure functions. // In C++, they're written as methods. diff --git a/icu4c/source/i18n/number_scientific.h b/icu4c/source/i18n/number_scientific.h index 6bdd24aa3c3..8ba60e94146 100644 --- a/icu4c/source/i18n/number_scientific.h +++ b/icu4c/source/i18n/number_scientific.h @@ -33,7 +33,7 @@ class U_I18N_API ScientificModifier : public UMemory, public Modifier { const ScientificHandler *fHandler; }; -class U_I18N_API ScientificHandler : public UMemory, public MicroPropsGenerator, public MultiplierProducer { +class ScientificHandler : public UMemory, public MicroPropsGenerator, public MultiplierProducer { public: ScientificHandler(const Notation *notation, const DecimalFormatSymbols *symbols, const MicroPropsGenerator *parent); diff --git a/icu4c/source/i18n/number_types.h b/icu4c/source/i18n/number_types.h index d652c523de8..b6ade0a4e25 100644 --- a/icu4c/source/i18n/number_types.h +++ b/icu4c/source/i18n/number_types.h @@ -94,7 +94,8 @@ enum CompactType { // TODO: Should this be moved somewhere else, maybe where other ICU classes can use it? -class CharSequence { +// Exported as U_I18N_API because it is a base class for other exported types +class U_I18N_API CharSequence { public: virtual ~CharSequence() = default; @@ -147,6 +148,8 @@ class U_I18N_API AffixPatternProvider { * * A Modifier is usually immutable, except in cases such as {@link MurkyModifier}, which are mutable for performance * reasons. + * + * Exported as U_I18N_API because it is a base class for other exported types */ class U_I18N_API Modifier { public: @@ -205,7 +208,7 @@ class U_I18N_API Modifier { * quantity-dependent. Each element in the linked list calls {@link #processQuantity} on its "parent", then does its * work, and then returns the result. * - * @author sffc + * Exported as U_I18N_API because it is a base class for other exported types * */ class U_I18N_API MicroPropsGenerator { @@ -231,8 +234,9 @@ class MultiplierProducer { virtual int32_t getMultiplier(int32_t magnitude) const = 0; }; +// Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties template -class NullableValue { +class U_I18N_API NullableValue { public: NullableValue() : fNull(true) {} diff --git a/icu4c/source/i18n/unicode/numberformatter.h b/icu4c/source/i18n/unicode/numberformatter.h index 5b6719fc0fb..2127f9dd48c 100644 --- a/icu4c/source/i18n/unicode/numberformatter.h +++ b/icu4c/source/i18n/unicode/numberformatter.h @@ -1818,7 +1818,9 @@ class U_I18N_API LocalizedNumberFormatter ~LocalizedNumberFormatter(); private: +#pragma warning(suppress: 4251) // 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 std::atomic fCallCount{0}; LocalizedNumberFormatter() = default;