From 9fc4161f5e905aef3cf8932334f4d5cf440c407a Mon Sep 17 00:00:00 2001 From: dspc-douglas Date: Wed, 22 Jan 2020 19:32:37 -0300 Subject: [PATCH] fix interal compiler error when building with mingw --- include/fmt/format-inl.h | 3 ++- src/format.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index dcad80ad..55bf1c44 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -1147,7 +1147,8 @@ int snprintf_float(T value, int precision, float_specs specs, "fuzz mode - avoid large allocation inside snprintf"); #endif // Suppress the warning about a nonliteral format string. - auto snprintf_ptr = FMT_SNPRINTF; + // Cannot use auto becase of a bug in MinGW (#1532). + int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF; int result = precision >= 0 ? snprintf_ptr(begin, capacity, format, precision, value) : snprintf_ptr(begin, capacity, format, value); diff --git a/src/format.cc b/src/format.cc index 44ba77f0..e6fde7c3 100644 --- a/src/format.cc +++ b/src/format.cc @@ -19,7 +19,7 @@ int format_float(char* buf, std::size_t size, const char* format, int precision, "fuzz mode - avoid large allocation inside snprintf"); #endif // Suppress the warning about nonliteral format string. - auto snprintf_ptr = FMT_SNPRINTF; + int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF; return precision < 0 ? snprintf_ptr(buf, size, format, value) : snprintf_ptr(buf, size, format, precision, value); }