From 87122b908466490d777ef94b04732489d5003e46 Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Fri, 25 May 2018 07:27:56 +0000 Subject: [PATCH] ICU-13775 Fix build issues on MinGW and Clang-for-Windows (with exported template instantiations). X-SVN-Rev: 41460 --- icu4c/source/i18n/number_utils.h | 22 ++++++++++-------- icu4c/source/i18n/numparse_affixes.h | 28 ++++++++++------------- icu4c/source/i18n/numparse_compositions.h | 19 +++++++-------- icu4c/source/i18n/numparse_impl.h | 8 ++++--- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/icu4c/source/i18n/number_utils.h b/icu4c/source/i18n/number_utils.h index 86f56983a40..e11da139422 100644 --- a/icu4c/source/i18n/number_utils.h +++ b/icu4c/source/i18n/number_utils.h @@ -18,7 +18,18 @@ #include "decNumber.h" #include "charstr.h" -U_NAMESPACE_BEGIN namespace number { +U_NAMESPACE_BEGIN + +#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 + +namespace number { namespace impl { struct MicroProps : public MicroPropsGenerator { @@ -192,15 +203,6 @@ 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 { diff --git a/icu4c/source/i18n/numparse_affixes.h b/icu4c/source/i18n/numparse_affixes.h index 5449d227da5..1a90b31b3e2 100644 --- a/icu4c/source/i18n/numparse_affixes.h +++ b/icu4c/source/i18n/numparse_affixes.h @@ -15,7 +15,8 @@ #include -U_NAMESPACE_BEGIN namespace numparse { +U_NAMESPACE_BEGIN +namespace numparse { namespace impl { // Forward-declaration of implementation classes for friending @@ -44,13 +45,6 @@ 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. */ @@ -163,14 +157,6 @@ 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. -// Also an explicit template instantiation of the MaybeStackArray that is used inside of the CompactUnicodeString. -// 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 MaybeStackArray; -template class U_I18N_API CompactUnicodeString<4>; -#endif // Exported as U_I18N_API for tests class U_I18N_API AffixPatternMatcher : public ArraySeriesMatcher { @@ -248,6 +234,16 @@ class AffixMatcherWarehouse { } // namespace impl } // namespace numparse + +// Export a explicit template instantiations of MaybeStackArray and CompactUnicodeString. +// When building DLLs for Windows this is required even though no direct access 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; +template class U_I18N_API MaybeStackArray; +template class U_I18N_API numparse::impl::CompactUnicodeString<4>; +#endif + U_NAMESPACE_END #endif //__NUMPARSE_AFFIXES_H__ diff --git a/icu4c/source/i18n/numparse_compositions.h b/icu4c/source/i18n/numparse_compositions.h index 2a993928da8..f085912def1 100644 --- a/icu4c/source/i18n/numparse_compositions.h +++ b/icu4c/source/i18n/numparse_compositions.h @@ -9,9 +9,17 @@ #include "numparse_types.h" -U_NAMESPACE_BEGIN namespace numparse { -namespace impl { +U_NAMESPACE_BEGIN + +// 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 +namespace numparse { +namespace impl { /** * Base class for AnyMatcher and SeriesMatcher. @@ -78,13 +86,6 @@ 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 0fd58e54925..e0e36071860 100644 --- a/icu4c/source/i18n/numparse_impl.h +++ b/icu4c/source/i18n/numparse_impl.h @@ -19,16 +19,18 @@ #include "numparse_validators.h" #include "number_multiplier.h" -U_NAMESPACE_BEGIN namespace numparse { -namespace impl { +U_NAMESPACE_BEGIN // 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; +template class U_I18N_API MaybeStackArray; #endif +namespace numparse { +namespace impl { + // Exported as U_I18N_API for tests class U_I18N_API NumberParserImpl : public MutableMatcherCollection { public: -- 2.40.0