From f5082ad3a7a4065eb95d6153ae1e0b5cdc938235 Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Wed, 2 May 2018 06:49:00 +0000 Subject: [PATCH] ICU-13725 Fix many of the C4251 warnings by DLL-exporting explicit template instantiations. X-SVN-Rev: 41306 --- icu4c/source/i18n/number_utils.h | 11 ++++++++++- icu4c/source/i18n/numparse_affixes.h | 13 +++++++++++++ icu4c/source/i18n/numparse_compositions.h | 6 ++++++ icu4c/source/i18n/numparse_impl.h | 7 +++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/number_utils.h b/icu4c/source/i18n/number_utils.h index bd35e21c705..2fdbb68b40b 100644 --- a/icu4c/source/i18n/number_utils.h +++ b/icu4c/source/i18n/number_utils.h @@ -115,6 +115,15 @@ getPatternForStyle(const Locale& locale, const char* nsName, CldrPatternStyle st } // namespace utils +#define DECNUM_INITIAL_CAPACITY 34 + + // Export an explicit template instantiation of the MaybeStackHeaderAndArray that is used as a data member of DecNum. + // When building DLLs for Windows this is required even though no direct access to the MaybeStackHeaderAndArray leaks out of the i18n library. + // (See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API MaybeStackHeaderAndArray; +#endif + /** A very thin C++ wrapper around decNumber.h */ // Exported as U_I18N_API for tests class U_I18N_API DecNum : public UMemory { @@ -151,7 +160,7 @@ class U_I18N_API DecNum : public UMemory { } private: - static constexpr int32_t kDefaultDigits = 34; + static constexpr int32_t kDefaultDigits = DECNUM_INITIAL_CAPACITY; MaybeStackHeaderAndArray fData; decContext fContext; diff --git a/icu4c/source/i18n/numparse_affixes.h b/icu4c/source/i18n/numparse_affixes.h index 933dcc7ea45..5318cf6d41c 100644 --- a/icu4c/source/i18n/numparse_affixes.h +++ b/icu4c/source/i18n/numparse_affixes.h @@ -44,6 +44,13 @@ class CodePointMatcher : public NumberParseMatcher, public UMemory { }; +// Export an explicit template instantiation of the MaybeStackArray that is used as a data member of CodePointMatcherWarehouse. +// When building DLLs for Windows this is required even though no direct access to the MaybeStackArray leaks out of the i18n library. +// (See numparse_compositions.h, digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API MaybeStackArray; +#endif + /** * A warehouse to retain ownership of CodePointMatchers. */ @@ -155,6 +162,12 @@ class AffixPatternMatcherBuilder : public TokenConsumer, public MutableMatcherCo void addMatcher(NumberParseMatcher& matcher) override; }; +// Export an explicit template instantiation of the CompactUnicodeString that is used as a data member of AffixPatternMatcher. +// When building DLLs for Windows this is required even though no direct access to the CompactUnicodeString leaks out of the i18n library. +// (See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API CompactUnicodeString<4>; +#endif // Exported as U_I18N_API for tests class U_I18N_API AffixPatternMatcher : public ArraySeriesMatcher { diff --git a/icu4c/source/i18n/numparse_compositions.h b/icu4c/source/i18n/numparse_compositions.h index 80aeb66e647..2a993928da8 100644 --- a/icu4c/source/i18n/numparse_compositions.h +++ b/icu4c/source/i18n/numparse_compositions.h @@ -78,6 +78,12 @@ class U_I18N_API SeriesMatcher : public CompositionMatcher { SeriesMatcher() = default; }; +// Export an explicit template instantiation of the MaybeStackArray that is used as a data member of ArraySeriesMatcher. +// When building DLLs for Windows this is required even though no direct access to the MaybeStackArray leaks out of the i18n library. +// (See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API MaybeStackArray; +#endif /** * An implementation of SeriesMatcher that references an array of matchers. diff --git a/icu4c/source/i18n/numparse_impl.h b/icu4c/source/i18n/numparse_impl.h index e4eac0e9c09..63c04802441 100644 --- a/icu4c/source/i18n/numparse_impl.h +++ b/icu4c/source/i18n/numparse_impl.h @@ -22,6 +22,13 @@ U_NAMESPACE_BEGIN namespace numparse { namespace impl { +// Export an explicit template instantiation of the MaybeStackArray that is used as a data member of NumberParserImpl. +// When building DLLs for Windows this is required even though no direct access to the MaybeStackArray leaks out of the i18n library. +// (See numparse_compositions.h, numparse_affixes.h, datefmt.h, and others for similar examples.) +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +template class U_I18N_API MaybeStackArray; +#endif + // Exported as U_I18N_API for tests class U_I18N_API NumberParserImpl : public MutableMatcherCollection { public: