From aba57bb9077da6012ad9f6b1a2185584d52b61a4 Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Mon, 18 May 2020 20:50:45 +0900 Subject: [PATCH] Support llvm-mingw(clang + libcxx) to open UTF-8 path in ifstream. --- tiny_gltf.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 9bba9c4..49c313b 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -2618,9 +2618,11 @@ bool ReadWholeFile(std::vector *out, std::string *err, _wopen(UTF8ToWchar(filepath).c_str(), _O_RDONLY | _O_BINARY); __gnu_cxx::stdio_filebuf wfile_buf(file_descriptor, std::ios_base::in); std::istream f(&wfile_buf); -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) || defined(_LIBCPP_VERSION) + // For libcxx, assume _LIBCPP_HAS_OPEN_WITH_WCHAR is defined to accept `wchar_t *` std::ifstream f(UTF8ToWchar(filepath).c_str(), std::ifstream::binary); -#else // clang? +#else + // Unknown compiler/runtime std::ifstream f(filepath.c_str(), std::ifstream::binary); #endif #else