]> granicus.if.org Git - icu/commitdiff
ICU-13725 Fix many of the C4251 warnings by DLL-exporting explicit template instantia...
authorJeff Genovy <29107334+jefgen@users.noreply.github.com>
Wed, 2 May 2018 06:49:00 +0000 (06:49 +0000)
committerJeff Genovy <29107334+jefgen@users.noreply.github.com>
Wed, 2 May 2018 06:49:00 +0000 (06:49 +0000)
X-SVN-Rev: 41306

icu4c/source/i18n/number_utils.h
icu4c/source/i18n/numparse_affixes.h
icu4c/source/i18n/numparse_compositions.h
icu4c/source/i18n/numparse_impl.h

index bd35e21c7056172e1d532d59b3e9db1553ccde21..2fdbb68b40b47df5ab75c0a6040d6fa10b0d5a27 100644 (file)
@@ -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<decNumber, char, DECNUM_INITIAL_CAPACITY>;
+#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<decNumber, char, kDefaultDigits> fData;
     decContext fContext;
 
index 933dcc7ea4574424a03f25bbc2097a7709a5f315..5318cf6d41cff47f5bab85f2ec0575d67130b59e 100644 (file)
@@ -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<CodePointMatcher*, 3>;
+#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 {
index 80aeb66e647ea3287e9460d4506603ecdee3b51d..2a993928da8c39a9466d2accc7e6a22cb464fd8e 100644 (file)
@@ -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<const NumberParseMatcher*, 3>;
+#endif
 
 /**
  * An implementation of SeriesMatcher that references an array of matchers.
index e4eac0e9c09681a90869ffcdcb0da2197c7c333c..63c04802441197fbffa63cfbf79aa1b3a0844b70 100644 (file)
 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<const NumberParseMatcher*, 10>;
+#endif
+
 // Exported as U_I18N_API for tests
 class U_I18N_API NumberParserImpl : public MutableMatcherCollection {
   public: