Fix building and using the library with MinGW -std=c++{98,11} options.
These options enable "strict ANSI" mode in MinGW which omits declarations of POSIX functions from the standard headers. To allow the library and, possibly even more importantly, the user code including our headers, to compile with these options, declare the functions that we need ourselves. This might appear to go against the spirit of "strict ANSI" mode, but the only alternative would be to not use such functions at all and silently cripple the library when -std=c++NN is used, compared to -std=g++NN case, and this doesn't seem appealing neither. Closes #16984.
This commit is contained in:
@@ -197,8 +197,22 @@ enum wxPosixPermissions
|
||||
#define wxFtell _ftelli64
|
||||
#elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc)
|
||||
#define wxHAS_HUGE_STDIO_FILES
|
||||
|
||||
wxDECL_FOR_STRICT_MINGW32(int, fseeko64, (FILE*, long long, int));
|
||||
#define wxFseek fseeko64
|
||||
#define wxFtell ftello64
|
||||
|
||||
#ifdef wxNEEDS_STRICT_ANSI_WORKAROUNDS
|
||||
// Unfortunately ftello64() is not defined in the library for
|
||||
// whatever reason but as an inline function, so define wxFtell()
|
||||
// here similarly.
|
||||
inline long long wxFtell(FILE* fp)
|
||||
{
|
||||
fpos_t pos;
|
||||
return fgetpos(fp, &pos) == 0 ? pos : -1LL;
|
||||
}
|
||||
#else
|
||||
#define wxFtell ftello64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// other Windows compilers (Borland) don't have huge file support (or at
|
||||
@@ -324,6 +338,9 @@ enum wxPosixPermissions
|
||||
#define wxCRT_OpenW _wopen
|
||||
#endif
|
||||
|
||||
wxDECL_FOR_STRICT_MINGW32(int, _wmkdir, (const wchar_t*))
|
||||
wxDECL_FOR_STRICT_MINGW32(int, _wrmdir, (const wchar_t*))
|
||||
|
||||
#define wxCRT_AccessW _waccess
|
||||
#define wxCRT_ChmodW _wchmod
|
||||
#define wxCRT_MkDirW _wmkdir
|
||||
|
Reference in New Issue
Block a user