Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#2,283 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
cpp
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu trong src/OpenColorIO/transforms/FileTransform.cpp và kiểm tra việc khởi tạo std::ifstream bằng Platform::filenameToUTF(filepath). Xây dựng OpenColorIO bằng GCC/MinGW-w64 hoặc MXE để tái hiện lỗi overload std::wstring, sau đó xác minh rằng việc xử lý đường dẫn biên dịch và hoạt động trên các cấu hình bị ảnh hưởng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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);
Ngôn ngữ chính
C++
Star
2.1k
Fork
502
Merge trung bình
6 ngày 3 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AcademySoftwareFoundation/OpenColorIO

Tất cả issue của AcademySoftwareFoundation/OpenColorIO

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.