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:
Vadim Zeitlin
2015-06-12 17:43:33 +02:00
parent e2410de134
commit aa30a2f97a
10 changed files with 99 additions and 3 deletions

View File

@@ -73,6 +73,9 @@
#ifdef wxNEED_ISASCII
inline int isascii(int c) { return (unsigned)c < 0x80; }
// Avoid further (re)definitions of it.
#define isascii isascii
#endif
#ifdef _WIN32_WCE
@@ -445,7 +448,7 @@ WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wcha
#else /* Unicode filenames */
/* special case: these functions are missing under Win9x with Unicows so we
have to implement them ourselves */
#if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__)
#if wxUSE_UNICODE_MSLU
WXDLLIMPEXP_BASE FILE* wxMSLU__wfopen(const wchar_t *name, const wchar_t *mode);
WXDLLIMPEXP_BASE FILE* wxMSLU__wfreopen(const wchar_t *name, const wchar_t *mode, FILE *stream);
WXDLLIMPEXP_BASE int wxMSLU__wrename(const wchar_t *oldname, const wchar_t *newname);
@@ -455,6 +458,11 @@ WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wcha
#define wxCRT_Remove wxMSLU__wremove
#define wxCRT_Rename wxMSLU__wrename
#else
wxDECL_FOR_STRICT_MINGW32(FILE*, _wfopen, (const wchar_t*, const wchar_t*))
wxDECL_FOR_STRICT_MINGW32(FILE*, _wfreopen, (const wchar_t*, const wchar_t*, FILE*))
wxDECL_FOR_STRICT_MINGW32(int, _wrename, (const wchar_t*, const wchar_t*))
wxDECL_FOR_STRICT_MINGW32(int, _wremove, (const wchar_t*))
/* WinCE CRT doesn't provide these functions so use our own */
#ifdef __WXWINCE__
WXDLLIMPEXP_BASE int wxCRT_Rename(const wchar_t *src,