From 5a34bfb1516a6719b5f470063c6be2f47446f0b2 Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Fri, 19 Oct 2018 16:19:24 -0700 Subject: [PATCH] ICU-20209 Fix build failures on Windows with std::atomic not in enclosing namespace std Also: Change to use the ICU namespace macro instead, and skip doxygen as well. --- icu4c/source/common/umutex.h | 14 +++++++++++--- icu4c/source/i18n/unicode/numberrangeformatter.h | 10 ++++++++-- icu4c/source/test/intltest/numbertest.h | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/icu4c/source/common/umutex.h b/icu4c/source/common/umutex.h index 015a12f9634..a15e7a4fc33 100644 --- a/icu4c/source/common/umutex.h +++ b/icu4c/source/common/umutex.h @@ -54,15 +54,23 @@ U_NAMESPACE_END #include -U_NAMESPACE_BEGIN - // Export an explicit template instantiation of std::atomic. // When building DLLs for Windows this is required as it is used as a data member of the exported SharedObject class. // See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples. -#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN +#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN && !defined(U_IN_DOXYGEN) + #if defined(__clang__) + // Suppress the warning that the explicit instantiation after explicit specialization has no effect. + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Winstantiation-after-specialization" + #endif template struct U_COMMON_API std::atomic; + #if defined(__clang__) + #pragma clang diagnostic pop + #endif #endif +U_NAMESPACE_BEGIN + typedef std::atomic u_atomic_int32_t; #define ATOMIC_INT32_T_INITIALIZER(val) ATOMIC_VAR_INIT(val) diff --git a/icu4c/source/i18n/unicode/numberrangeformatter.h b/icu4c/source/i18n/unicode/numberrangeformatter.h index 62d6100545e..d5466b12766 100644 --- a/icu4c/source/i18n/unicode/numberrangeformatter.h +++ b/icu4c/source/i18n/unicode/numberrangeformatter.h @@ -185,8 +185,14 @@ class NumberRangeFormatterImpl; * Export an explicit template instantiation. See datefmt.h * (When building DLLs for Windows this is required.) */ -#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM < U_PF_CYGWIN && !defined(U_IN_DOXYGEN) -template struct U_I18N_API std::atomic; +#if U_PLATFORM == U_PF_WINDOWS && !defined(U_IN_DOXYGEN) +} // namespace icu::number +U_NAMESPACE_END + +template struct U_I18N_API std::atomic< U_NAMESPACE_QUALIFIER number::impl::NumberRangeFormatterImpl*>; + +U_NAMESPACE_BEGIN +namespace number { // icu::number #endif /** \endcond */ diff --git a/icu4c/source/test/intltest/numbertest.h b/icu4c/source/test/intltest/numbertest.h index 49c2d4411a9..1c109df5b6a 100644 --- a/icu4c/source/test/intltest/numbertest.h +++ b/icu4c/source/test/intltest/numbertest.h @@ -10,6 +10,7 @@ #include "intltest.h" #include "number_affixutils.h" #include "numparse_stringsegment.h" +#include "numrange_impl.h" #include "unicode/locid.h" #include "unicode/numberformatter.h" #include "unicode/numberrangeformatter.h"