さらば、すべてのエヴァンゲリオン

MinGW-w64

Mingw-w64项目包含对GCCGNU Binutils的Windows版本的移植汇编器链接器库文件管理器),一套自由可分发的Windows特定的头文件静态导入库以使用Windows API,一个Windows本地版本的GNU调试器,以及其它多种工具。

维护着一个类似于pthreads-win32winpthreads包装库libwinpthread), 实现了C++11线程库<thread>, <future>, <mutex>

各种版本

1MinGW64/32 msvcrt libstdc++ gcc
2
3UCRT64 UCRT libstdc++ gcc
4
5CLANG64 UCRT libc++ clang

MSVCRT (Microsoft Visual C++ Runtime) is available by default on all Microsoft Windows versions, but due to backwards compatibility issues is stuck in the past, not C99 compatible and is missing some features.Binaries linked with MSVCRT should not be mixed with UCRT ones because the internal structures and data types are different. (More strictly, object files or static libraries built for different targets should not be mixed. DLLs built for different CRTs can be mixed as long as they do not share CRT objects).

UCRT only ships by default on Windows 10 and for older versions you have to provide it yourself or depend on the user having it installed.

MSVCRT 开箱即用 UCRT (MSVC uses UCRT by default) 但是只支持Windows10以上的系统,否则需要自行安装运行时

 1# 可能带libwinpthread-1.dll的动态库 
 2# how to make winpthread static ? ->
 3# I think I get it... I need libwinpthread-1.dll only if I compile with static libstdc++,
 4# meaning in my environment (arch and official repositories) static version of libstdc++ depends on shared winpthread. 
 5# To get around this I probably need to compile mingw-w64 myself.
 6g++ .\test.cpp -I some_path\include -O3 -Wall -static -std=c++17 -o a.exe
 7
 8# powershell "-Wl,--no-needed"
 9
10clang++ .\test.cpp -I some_path\include -O3 -Wall -static -std=c++17 -o a.exe

MinGW MinGW64 Cygwin msys2

1msys2 Cygwin魔改,arch模式 pacman包管理
2Cywin POSIX系统的模拟 系统内gcc编译的软件需要配 cywin1.dll 内含 mingw64 套件
3MinGW64 Windows下的GNU编译器 自带包装库翻译用 依赖如上节(系统自带开箱即用)
4MinGW MinGW64的前身,接口有区别

MSVC

Variable Length Arrays

Astute readers will note that VLAs are also not supported. Variable length arrays are generally less efficient than comparable fixed sized arrays, and generally inefficient compared to equivalent malloc(), when safely and securely implemented. VLAs provide attack vectors comparable to those of the infamous gets() — deprecated and destined to removal — for opportunities of “shifting the stack” and other exploits. For these reasons we intend not to support VLAs as an optional feature in C11.

1# 替代方法
2int *array = (int*)malloc(n*sizeof(int));

总之C++C的标准支持情况不好,不推荐。C#还行C++属实折磨,工程的配置文件.sln也是要命。