Fix compilation after fpos_t change in with MinGW runtime 5.2

fpos_t is now a union and not just a simple typedef any more, so we
can't cast between it and long long. Unfortunately we still need to
convert between the two, so add an explicit version check and use the
private union field to make this work with the latest MinGW 32 versions.
This commit is contained in:
Vadim Zeitlin
2019-10-06 00:13:26 +02:00
parent 80d0496689
commit 2c604863de

View File

@@ -162,7 +162,21 @@ enum wxPosixPermissions
inline long long wxFtell(FILE* fp)
{
fpos_t pos;
return fgetpos(fp, &pos) == 0 ? pos : static_cast<fpos_t>(-1LL);
if ( fgetpos(fp, &pos) != 0 )
return -1LL;
// Unfortunately our interface assumes that the file position
// is representable as "long long", so we have to get it from
// fpos_t, even though it's an opaque type. And its exact
// representation has changed in MinGW, so we have to test for
// mingwrt version.
#if wxCHECK_MINGW32_VERSION(5, 2)
// In 5.2.2 it's a union with a __value field.
return pos.__value;
#else
// Up to 5.1.1 it was a simple typedef.
return pos;
#endif
}
#else
#define wxFtell ftello64