diff --git a/fmt/format.cc b/fmt/format.cc index 0efcbb6f..5fbfd5ed 100644 --- a/fmt/format.cc +++ b/fmt/format.cc @@ -99,31 +99,6 @@ const char fmt::internal::BasicData::DIGITS[] = "6061626364656667686970717273747576777879" "8081828384858687888990919293949596979899"; -#define FMT_POWERS_OF_10(factor) \ - factor * 10, \ - factor * 100, \ - factor * 1000, \ - factor * 10000, \ - factor * 100000, \ - factor * 1000000, \ - factor * 10000000, \ - factor * 100000000, \ - factor * 1000000000 - -template -const uint32_t fmt::internal::BasicData::POWERS_OF_10_32[] = { - 0, FMT_POWERS_OF_10(1) -}; - -template -const uint64_t fmt::internal::BasicData::POWERS_OF_10_64[] = { - 0, - FMT_POWERS_OF_10(1), - FMT_POWERS_OF_10(fmt::ULongLong(1000000000)), - // Multiply several constants instead of using a single long long constant - // to avoid warnings about C++98 not supporting long long. - fmt::ULongLong(1000000000) * fmt::ULongLong(1000000000) * 10 -}; FMT_FUNC void fmt::internal::report_unknown_type(char code, const char *type) { (void)type; diff --git a/fmt/format.h b/fmt/format.h index bf71e2da..6a4f6099 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -836,15 +836,45 @@ struct FMT_API BasicData { static const char DIGITS[]; }; -#ifndef FMT_USE_EXTERN_TEMPLATES -// Clang doesn't have a feature check for extern templates so we check -// for variadic templates which were introduced in the same version. -# define FMT_USE_EXTERN_TEMPLATES (__clang__ && FMT_USE_VARIADIC_TEMPLATES) -#endif +#define FMT_POWERS_OF_10(factor) \ + factor * 10, \ + factor * 100, \ + factor * 1000, \ + factor * 10000, \ + factor * 100000, \ + factor * 1000000, \ + factor * 10000000, \ + factor * 100000000, \ + factor * 1000000000 -#if FMT_USE_EXTERN_TEMPLATES -extern template struct BasicData; -#endif +template +const uint32_t BasicData::POWERS_OF_10_32[] = { + 0, FMT_POWERS_OF_10(1) +}; + +template +const uint64_t fmt::internal::BasicData::POWERS_OF_10_64[] = { + 0, + FMT_POWERS_OF_10(1), + FMT_POWERS_OF_10(fmt::ULongLong(1000000000)), + // Multiply several constants instead of using a single long long constant + // to avoid warnings about C++98 not supporting long long. + fmt::ULongLong(1000000000) * fmt::ULongLong(1000000000) * 10 +}; + + + +/// After the changes for 335, cland reported unedefined references to +/// BasicData, so I put their definitions in the header. +// #ifndef FMT_USE_EXTERN_TEMPLATES +// // Clang doesn't have a feature check for extern templates so we check +// // for variadic templates which were introduced in the same version. +// # define FMT_USE_EXTERN_TEMPLATES (__clang__ && FMT_USE_VARIADIC_TEMPLATES) +// #endif + +// #if FMT_USE_EXTERN_TEMPLATES +// extern template struct BasicData; +// #endif typedef BasicData<> Data;