Closed dennisferron closed 4 years ago
I'd like to fix this and send a pull request, but it looks like the only portable way to do the encoding conversion, std::codecvt_utf8_utf16, was introduced with C++11 and deprecated (without a replacement!) in C++17.
Zooming out to the larger scope, I see an alternative would be to use a wide char version of the file open function, and that's exactly what you've already did if _MSC_VER is defined (the compile error occurred in the preprocessing branch for MINGW32 and not _MSC_VER. If I change the preprocessor guards so that I use the _MSC_VER of TAO_PEGTL_NAMESPACE::internal::file_open's implementation using ::_wfopen_s it does compile.
However then I get a linker error: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
Lots of platforms still require linking against a separate filesystem library (-lfilesystem
), try adding that?
@dennisferron Does -lfilesystem
fix the linker error with your patched code?
Thanks for the pull request, hopefully this will work for everybody :-)
On Windows 10, compiling with gcc on mingw / msys2, std::filesystem::path::c_str() returns a const wchar_t while std::fopen takes a const char_t. This causes a compile error.
You won't be able to fix it with a simple cast. It will require a UTF-16LE aware string conversion.