From b2c5f668826421fd7155a37243eb61f5133fc1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Wed, 24 Jun 2026 06:22:42 -0400 Subject: [PATCH] windows: open files via std::filesystem::path so libc++ accepts wide paths base/file_sys.h's path::open() built a std::ifstream straight from the std::wstring w_path_ on Windows. That ctor overload is a Microsoft-STL extension; libc++ (the clang Windows toolchain) does not provide it, so the header fails to compile with "no matching constructor for initialization of 'std::ifstream'". Construct a std::filesystem::path from the wide string instead -- basic_ifstream's filesystem::path ctor is standard C++17, honoured by libc++/libstdc++/MSVC STL, and still preserves the UTF-16 path. Fixes #1071. --- base/file_sys.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/base/file_sys.h b/base/file_sys.h index 92f845b37..f6e29b834 100644 --- a/base/file_sys.h +++ b/base/file_sys.h @@ -18,6 +18,7 @@ #include #include +#include namespace ort_extensions { @@ -51,7 +52,12 @@ class path { std::ifstream open(ios_base::openmode mode = ios_base::in) const { // if Windows, need to convert the string to UTF-16 #ifdef _WIN32 - return std::ifstream(w_path_, mode); + // libc++ (the Windows clang toolchain) provides no std::ifstream ctor + // taking a std::wstring -- that overload is an MSVC-STL extension. Route + // the wide path through std::filesystem::path, whose basic_ifstream ctor + // overload is standard C++17 and is honoured by libc++/libstdc++/MSVC STL + // alike, while still preserving the UTF-16 path. (microsoft/onnxruntime-extensions#1071) + return std::ifstream(std::filesystem::path(w_path_), mode); #else return std::ifstream(path_, mode); #endif // _WIN32