跳到正文

个人记录

MinGW-w64 GCC 8 版本罕见的 bug

Zjl37约 3 分钟
原文
文章信息与版本

文章信息

发布
2021年7月22日
收录
2025年12月12日
更新
2026年11月13日
篇幅
约 3 分钟

版本

  1. v1当前

1. 包括了 <bits/stdc++.h> 不能用 C++17 编译

C++
In file included from R:/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/filesystem:37,
                 from R:/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32/bits/stdc++.h:127,
                 from C:\Users\administered\OneDrive\OIer\test.cpp:1:
R:/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h: In member function 'std::filesystem::__cxx11::path& std::filesystem::__cxx11::path::operator/=(const std::filesystem::__cxx11::path&)':
R:/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:237:47: error: no match for 'operator!=' (operand types are 'std::filesystem::__cxx11::path' and 'std::filesystem::__cxx11::path')
    || (__p.has_root_name() && __p.root_name() != root_name()))
                               ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
...
... (and 1.5k more lines!!)

g++ 的开发者:我大意了啊,忘了在 Windows 下测试,把 <filesystem> 头文件写挂了。

这个 bug 已在 9 版本中修复。

2. <windows.h> 不够新

如果你搞一点 Windows 开发,追求微软一些较新的技术,你可能会发现。

比如你发现一个 Console 的 api 没有定义 ENABLE_VIRTUAL_TERMINAL_PROCESSING,那么你可能要在文档中查看一下他的值,手动 #define 一下。

3. 头文件与 clang 不大兼容

用 clang++ 编译,会莫名其妙的对 <float.h> 报错。


Sol

用更新的 GCC 11.1.0。mingw-w64 的官网尚未有构建,已有人构建好了:winlibs

原文