Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Build failure on GCC/MinGW (MXE): std::ifstream constructor mismatch with Platform::filenameToUTF()

未关闭 适合新手
#2,283 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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::wstring on _WIN32 && UNICODE
  • std::string otherwise
  • std::ifstream construction from std::wstring is 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AcademySoftwareFoundation/OpenColorIO 的其他 Issue

查看 AcademySoftwareFoundation/OpenColorIO 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。