MSVCRT vs UCRT
These are two variants of the C standard library on Microsoft Windows.
MSVCRT
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.
- It isn't C99 compatible, for example the printf() function family, but...
- mingw-w64 provides replacement functions to make things C99 compatible in many cases
- It doesn't support the UTF-8 locale
- 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 shouldn't be mixed. DLLs built for different CRTs can be mixed as long as they don't share CRT objects, e.g. FILE*, across DLL boundaries.) Same rule is applied for MSVC compiled binaries because MSVC uses UCRT by default (if not changed).
- Works out of the box on every version of Microsoft Windows.
UCRT
UCRT (Universal C Runtime) is a newer version which is also used by Visual Studio 2015+ by default.
- Better compatibility with MSVC, both at build time and at run time.
- It is included as part of the operating system in Windows 10 or later.
Win10+
Current LTSC:
- Win10 2019
Future LTSC:
- Win11 27H2
UCRT的历史
- 早期的设计
- 正式版本
早期的设计
当vs2015还在CTP阶段时,微软的设想是将VC运行时库拆分成三部分。
vcruntime140.dll 包含运行期需要处理的功能,如:进程启动、异常处理、以及耦合到相关编译器的功能。
appcrt140.dll包含所有平台上都可用的所有功能,且以后保持这部分CRT的向后兼容性。
包括:堆、数学库、stdio库、locale库、大多数字符串操作函数、时间库和一些其他功能等。
desktopcrt140.dll包含所有只能由桌面应用程序使用的功能,且以后保持这部分CRT的向后兼容性。
包括:处理多字节字符串、exec和spawn进程管理函数、direct-to-console I/O函数的功能等等。
正式版本
在最终发布正式版的时候,微软将appcrt140.dll和desktopcrt140.dll合并为一个不带版本号的程序库:ucrtbase.dll。
它对应的Debug版本的命名是ucrtbased.dll。这个后来被正式命名为“the Universal CRT”。
浙公网安备 33010602011771号