Skip to content

Commit

Permalink
Use _wfopen and fseeko64 on MinGW in C++11 mode
Browse files Browse the repository at this point in the history
Since MinGW 4.5 does not define these functions if __STRICT_ANSI__ is defined
(in case of _wfopen it defines it inconsistently between stdio.h and wchar.h)
use the baseline functions for MinGW 4.5 and earlier.

Fixes zeux#23.
  • Loading branch information
zeux committed Nov 25, 2014
1 parent 3e1ae89 commit b7a1fec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3995,7 +3995,7 @@ PUGI__NS_BEGIN
_fseeki64(file, 0, SEEK_END);
length_type length = _ftelli64(file);
_fseeki64(file, 0, SEEK_SET);
#elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && !defined(__STRICT_ANSI__)
#elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && !(defined(__STRICT_ANSI__) && __GNUC__ * 100 + __GNUC_MINOR__ <= 405)
// there are 64-bit versions of fseek/ftell, let's use them
typedef off64_t length_type;

Expand Down Expand Up @@ -4240,7 +4240,7 @@ PUGI__NS_BEGIN
}
#endif

#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && !defined(__STRICT_ANSI__))
#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && !(defined(__STRICT_ANSI__) && __GNUC__ * 100 + __GNUC_MINOR__ <= 405))
PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode)
{
return _wfopen(path, mode);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ TEST(document_load_file_wide_ascii)
CHECK_NODE(doc, STR("<node />"));
}

#if !defined(__DMC__) && !defined(__MWERKS__)
#if !defined(__DMC__) && !defined(__MWERKS__) && !(defined(__MINGW32__) && defined(__STRICT_ANSI__) && __GNUC__ * 100 + __GNUC_MINOR__ <= 405)
TEST(document_load_file_wide_unicode)
{
pugi::xml_document doc;
Expand Down

0 comments on commit b7a1fec

Please sign in to comment.