When i tried to build a console app using the header-only version, got the following error:
In file included from ../fmt/include/fmt/format.h:3536,
from ../main.cpp:4:
../fmt/include/fmt/format-inl.h: In function 'int fmt::v6::internal::snprintf_float(T, int, fmt::v6::internal::float_specs, fmt::v6::internal::buffer&)':
../fmt/include/fmt/format-inl.h:69:25: internal compiler error: _Segmentation fault_
#define FMT_SNPRINTF snprintf
../fmt/include/fmt/format-inl.h:1163:25: note: in expansion of macro 'FMT_SNPRINTF'
auto snprintf_ptr = FMT_SNPRINTF;
This was caused by the snprintf assignment to snprintf_ptr variable. I was able to build successfully after a few changes:
Line 64, change:
#define FMT_SNPRINTF snprintf
To:
#if defined(__MINGW32__)
int (*psnprintf)(char*, std::size_t, char const*, ...) = std::snprintf;
#define FMT_SNPRINTF psnprintf
#else
#define FMT_SNPRINTF snprintf
#endif
Does changing
to
int (*snprintf_ptr)(char*, std::size_t, char const*, ...) = FMT_SNPRINTF;
and similarly in https://github.com/fmtlib/fmt/blob/25d6916b3ae5602a5cb1cf1bb8be1de3d2ecbd0f/src/format.cc#L22 also "fix" the internal compiler error?
Yes, it works as well.
Great, thanks for checking. Could you submit a PR with these two small changes and a comment that it's a workaround for MinGW?
Sure
@ryusakki, could you also post your compiler version here for future reference?