Build failure on GCC/MinGW (MXE): std::ifstream constructor mismatch with Platform::filenameToUTF()
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- cpp
- 领域
- build-system
调研方向
从 src/OpenColorIO/transforms/FileTransform.cpp 开始,检查使用 Platform::filenameToUTF(filepath) 构造 std::ifstream 的代码。使用 GCC/MinGW-w64 或 MXE 构建 OpenColorIO,以复现 std::wstring 重载失败,然后验证路径处理在受影响的配置下能够编译并正常工作。
由索引模型根据 Issue 内容生成。
描述
Description
OpenColorIO 2.5.1 fails to compile under GCC / MinGW-w64 (including MXE cross builds) due to inconsistent file path type handling in Platform::filenameToUTF() when used with std::ifstream in FileTransform.cpp.
The failure occurs when constructing a std::ifstream from the result of Platform::filenameToUTF(filepath), where the returned type may vary between std::string and std::wstring depending on build configuration (_WIN32 && UNICODE).
This leads to template overload resolution failures under GCC/libstdc++ when a std::wstring is involved in std::ifstream construction.
Error observed (GCC / libstdc++)
error: no matching function for call to
std::basic_ifstream<char>::basic_ifstream(const std::wstring, std::ios_base::openmode)
Affected code src/OpenColorIO/transforms/FileTransform.cpp:
std::ifstream(Platform::filenameToUTF(filepath), mode)
Root cause
Platform::filenameToUTF()is conditionally typed:std::wstringon _WIN32 && UNICODEstd::stringotherwisestd::ifstreamconstruction fromstd::wstringis not consistently supported across standard library implementations- GCC/libstdc++ rejects this usage, while MSVC may accept it depending on STL implementation details
- This creates a portability issue in file I/O path handling
Impact
- Breaks MXE / MinGW-w64 cross compilation
- Causes divergence between MSVC and GCC builds
- Introduces non-portable file path handling in core I/O utilities
Suggested fix
Avoid passing platform-dependent string types directly into std::ifstream construction.
This is the C++17-compatible solution that worked:
auto path = Platform::filenameToUTF(filepath);
return std::make_unique<std::ifstream>(path.c_str(), mode);
- 主要语言
- C++
- 星标
- 2.1k
- 派生
- 502
- 平均合并
- 6 天 3 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AcademySoftwareFoundation/OpenColorIO 的其他 Issue
-
Inconsistent run-time library usage for locale handling breaks GPU code generation on some systems.未关闭
难度 2/5 1-3 小时 新手友好度 86/100
AcademySoftwareFoundation/OpenColorIO#2351 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
AcademySoftwareFoundation/OpenColorIO#2340 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
AcademySoftwareFoundation/OpenColorIO#2329 ·
维护者通常 1 天内回复
-
Documentation
难度 1/5 1 小时以内 新手友好度 72/100
AcademySoftwareFoundation/OpenColorIO#2280 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
AcademySoftwareFoundation/OpenColorIO#2277 ·
维护者通常 1 天内回复
查看 AcademySoftwareFoundation/OpenColorIO 的全部 Issue
相似的 Issue
-
agent:WSL bug code-review linux LOW
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
category:port-update
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复
-
[BUG] SOLE B94 (current model): Set Target Resistance Level rejected with 80 04 03 – bike expects 0.1 units可能已有人在做 @cagnulein 今天认领。 未关闭
难度 2/5 半天 新手友好度 78/100
cagnulein/qdomyos-zwift#5380 · 1 条评论 ·
维护者通常 1 天内回复
-
improvement ui
难度 2/5 1-3 小时 新手友好度 72/100
ihhub/fheroes2#11062 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复