From 44639b11fecc8d69a7351afb2f20c1d3f8b8a825 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Thu, 7 May 2020 14:14:07 +0100 Subject: [PATCH] Fix some warnings (#1667) * Fix sign-conversion warning * Add missing "extern template" declarations for non-header-only build * Use typed enums to fix Wsigned-enum-bitfield warnings * Consolidate FMT_HEADER_ONLY code --- include/fmt/format.h | 26 ++++++++++++++++++++++++-- include/fmt/printf.h | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index b828ad29..7cb2a042 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1022,12 +1022,12 @@ template struct fill_t { // We cannot use enum classes as bit fields because of a gcc bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. namespace align { -enum type { none, left, right, center, numeric }; +enum type : uint8_t { none, left, right, center, numeric }; } using align_t = align::type; namespace sign { -enum type { none, minus, plus, space }; +enum type : uint8_t { none, minus, plus, space }; } using sign_t = sign::type; @@ -3331,6 +3331,28 @@ typename buffer_context::iterator internal::vformat_to( #ifndef FMT_HEADER_ONLY extern template format_context::iterator internal::vformat_to( internal::buffer&, string_view, basic_format_args); +namespace internal { +extern template FMT_API std::string grouping_impl(locale_ref loc); +extern template FMT_API std::string grouping_impl(locale_ref loc); +extern template FMT_API char thousands_sep_impl(locale_ref loc); +extern template FMT_API wchar_t thousands_sep_impl(locale_ref loc); +extern template FMT_API char decimal_point_impl(locale_ref loc); +extern template FMT_API wchar_t decimal_point_impl(locale_ref loc); +extern template +int format_float(double value, int precision, float_specs specs, + buffer& buf); +extern template +int format_float(long double value, int precision, + float_specs specs, buffer& buf); +int snprintf_float(float value, int precision, float_specs specs, + buffer& buf) = delete; +extern template +int snprintf_float(double value, int precision, float_specs specs, + buffer& buf); +extern template +int snprintf_float(long double value, int precision, + float_specs specs, buffer& buf); +} #endif template , diff --git a/include/fmt/printf.h b/include/fmt/printf.h index ed84f1b2..6f2c2ada 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -507,7 +507,7 @@ OutputIt basic_printf_context::format() { auto str_end = str + specs.precision; auto nul = std::find(str, str_end, Char()); arg = internal::make_arg(basic_string_view( - str, nul != str_end ? nul - str : specs.precision)); + str, internal::to_unsigned(nul != str_end ? nul - str : specs.precision))); } if (specs.alt && visit_format_arg(internal::is_zero_int(), arg)) specs.alt = false;