- Обновление кода для универсальной среды выполнения Upgrade your code to the Universal CRT
- Где найти файлы универсальной среды выполнения Where to find the Universal CRT files
- Развертывание и распространение универсальной среды выполнения Deployment and redistribution of the Universal CRT
- Изменения функций и макросов универсальной среды выполнения Changes to the Universal CRT functions and macros
Обновление кода для универсальной среды выполнения Upgrade your code to the Universal CRT
В Visual Studio 2015 был выполнен рефакторинг библиотеки времени выполнения Майкрософт C (CRT). In Visual Studio 2015, the Microsoft C Runtime Library (CRT) was refactored. Расширения стандартной библиотеки C, POSIX и характерные для Майкрософт функции были перемещены в новую библиотеку — библиотеку универсальной среды C (универсальной CRT или UCRT). The Standard C Library, POSIX extensions and Microsoft-specific functions, macros, and global variables were moved into a new library, the Universal C Runtime Library (Universal CRT or UCRT). Компоненты компилятора были перемещены в новую библиотеку vcruntime. The compiler-specific components of the CRT were moved into a new vcruntime library.
UCRT теперь является компонентом Windows и поставляется в составе Windows 10. The UCRT is now a Windows component, and ships as part of Windows 10. UCRT поддерживает стабильные соглашения о вызовах ABI на основе C и более точно соответствует стандарту ISO C99 с несколькими исключениями. The UCRT supports a stable ABI based on C calling conventions, and it conforms closely to the ISO C99 standard, with only a few exceptions. UCRT больше не привязана к конкретной версии компилятора. It is no longer tied to a specific version of the compiler. UCRT можно использовать в любой версии Windows, поддерживаемой Visual Studio 2015 или Visual Studio 2017. You can use the UCRT on any version of Windows supported by Visual Studio 2015 or Visual Studio 2017. Преимущество в том, что больше не требуется обновлять сборки для соответствия новой версии CRT при каждом обновлении Visual Studio. The benefit is that you no longer need to update your builds to target a new version of the CRT with every upgrade of Visual Studio.
После такого рефакторинга изменились имена или расположения многих файлов заголовков CRT, файлов библиотек и распространяемых компонентов, а также методы развертывания, необходимые для кода. With this refactoring, the names or locations of many CRT header files, library files, and redistributables, and the deployment methods required for your code have changed. Кроме того, в UCRT были добавлены или изменены многие функции и макросы в целях улучшения соответствия стандартам. In addition, many functions and macros in the UCRT were added or changed to improve standards conformance. Чтобы эффективно использовать эти изменения, необходимо обновить существующий код и системы сборки проекта. To take advantage of these changes, your existing code and project build systems must be updated.
Где найти файлы универсальной среды выполнения Where to find the Universal CRT files
Так как UCRT является компонентом Windows, файлы и заголовки библиотеки UCRT теперь входят в состав пакета SDK Windows. As a Windows component, the UCRT library files and headers are now part of the Windows software development kit (SDK). При установке Visual Studio также устанавливаются компоненты пакета SDK Windows, необходимые для использования UCRT. When you install Visual Studio, the parts of the Windows SDK required to use the UCRT are also installed. Установщик Visual Studio добавляет расположения файлов заголовков и библиотек и DLL-файлов в пути по умолчанию, используемые в системе сборки проектов Visual Studio. The Visual Studio installer adds the locations of the UCRT headers, libraries and DLL files to the default paths used by the Visual Studio project build system. Если при обновлении проекты Visual Studio C++ используют параметры по умолчанию, интегрированная среда разработки автоматически обнаружит новые расположения для файлов заголовков, а компоновщик автоматически будет использовать новые заданные по умолчанию библиотеки UCRT и vcruntime. When you update your Visual Studio C++ projects, if they use the default project settings, the IDE automatically finds the new locations for header files, and the linker automatically uses the new default UCRT and vcruntime libraries. Аналогичным образом при использовании командной строки разработчика для построений из командной строки переменные среды, содержащие пути для заголовков и библиотек, будут автоматически обновлены и готовы к работе. Similarly, if you use a Developer command prompt to do command-line builds, the environment variables that contain paths for headers and libraries are updated and work automatically as well.
Теперь файлы заголовков стандартной библиотеки C находятся в пакете SDK Windows SDK в папке include в каталоге версии пакета SDK. The Standard C Library header files are now found in the Windows SDK in an include folder in an SDK version-specific directory. Типичное расположение файлов заголовков находится в каталоге Program Files или Program Files (x86) в наборах Windows \ 10 с \ \ пакетом SDK-Version \ ucrt, где SDK-Version соответствует версии или обновлении Windows, например 10.0.14393.0 для годовщины обновления Windows 10. A typical location for the header files is in the Program Files or Program Files (x86) directory under Windows Kits\10\Include\sdk-version\ucrt, where sdk-version corresponds to a Windows version or update, for example, 10.0.14393.0 for the Anniversary Update of Windows 10.
Статические библиотеки UCRT и библиотеки заглушек динамической компоновки находятся в каталоге Program Files или Program Files (x86) в наборе Windows \ 10 \ lib \ SDK-Version \ UCRT \ , где архитектура — ARM, x86 или x64. The UCRT static libraries and dynamic link stub libraries are found in the Program Files or Program Files (x86) directory under Windows Kits\10\Lib\sdk-version\ucrt\architecture, where architecture is ARM, x86, or X64. Статические библиотеки отладочных и розничных версий — это libucrt.lib и libucrtd.lib, а библиотеки для DLL UCRT — ucrt.lib и ucrtd.lib. The retail and debug static libraries are libucrt.lib and libucrtd.lib, and the libraries for the UCRT DLLs are ucrt.lib and ucrtd.lib.
Отладочные и розничные версии библиотек DLL среды UCRT находятся в разных местах. The retail and debug UCRT DLLs are found in separate locations. Розничные библиотеки DLL являются распространяемыми, и их можно найти в каталоге Program Files или Program Files (x86) в комплектах Windows \ 10 \ Redist \ ucrt \ DLL \ .. The retail DLLs are redistributable, and can be found in the Program Files or Program Files (x86) directory under Windows Kits\10\Redist\ucrt\DLLs\architecture. Отладочные библиотеки UCRT не являются распространяемыми, и их можно найти в каталоге Program Files или Program Files (x86) в разделе Наборы Windows \ 10 \ bin \ архитектура \ UCRT. Debug UCRT libraries are not redistributable, and can be found in the Program Files or Program Files (x86) directory under Windows Kits\10\bin\architecture\ucrt folder.
Библиотека поддержки времени выполнения для компилятора C и C++, vcruntime, содержит код, необходимый для поддержки запуска программы и функций, таких как обработка исключений и встроенные функции. The C and C++ compiler-specific runtime support library, vcruntime, contains the code required to support program startup and features such as exception handling and intrinsics. Библиотеки и ее файлы заголовков по-прежнему находятся в папке конкретной версии Microsoft Visual Studio в каталоге Program Files или Program Files (x86). The library and its header files are still found in the version-specific Microsoft Visual Studio folder in your Program Files or Program files (x86) directory. В Visual Studio 2017 заголовки находятся в разделе Microsoft Visual Studio \ 2017 \ выпусков \ VC \ Tools \ компилятором MSVC \ lib-version, \ а библиотеки ссылок находятся в разделе Microsoft Visual Studio \ 2017 \ Edition \ VC \ Tools \ компилятором MSVC Library \ -Version \ lib \ , где Edition — это версия установленных Visual Studio, lib-Version является версией библиотек, а архитектура — архитектурой процессора. In Visual Studio 2017, the headers are found under Microsoft Visual Studio\2017\edition\VC\Tools\MSVC\lib-version\include and the link libraries are found under Microsoft Visual Studio\2017\edition\VC\Tools\MSVC\lib-version\lib\architecture, where edition is the edition of Visual Studio installed, lib-version is the version of the libraries, and architecture is the processor architecture. Библиотеки компоновки для OneCore и Магазина также находятся в папке библиотек. Link libraries for OneCore and Store are also found in the libraries folder. Версия выпуска и отладочная версия статической библиотеки — это libvcruntime.lib и libvcruntimed.lib. The retail and debug versions of the static library are libvcruntime.lib and libvcruntimed.lib. Версия выпуска библиотеки динамической компоновки и отладочная версия библиотеки заглушки — это vcruntime.lib и vcruntimed.lib, соответственно. The dynamic link retail and debug stub libraries are vcruntime.lib and vcruntimed.lib, respectively.
Если при обновлении проектов Visual Studio C++ вы установили для свойства Игнорировать все стандартные библиотеки****компоновщика в проекте значение Да или используете параметр компоновщика /NODEFAULTLIB в командной строке, необходимо обновить список библиотек, чтобы включить в него новые подвергнутые рефакторингу библиотеки. When you update your Visual Studio C++ projects, if you have set the project’s Linker property Ignore All Default Libraries to Yes or if you use the /NODEFAULTLIB linker option on the command line, then you must update your list of libraries to include the new, refactored libraries. Замените старую библиотеку CRT, например libcmt.lib, libcmtd.lib, msvcrt.lib, msvcrtd.lib, эквивалентными подвергнутыми рефакторингу библиотеками. Replace the old CRT library, for example, libcmt.lib, libcmtd.lib, msvcrt.lib, or msvcrtd.lib, with the equivalent refactored libraries. Сведения о конкретных библиотеках см. в разделе Особенности библиотеки CRT. For information on the specific libraries to use, see CRT Library Features.
Развертывание и распространение универсальной среды выполнения Deployment and redistribution of the Universal CRT
Поскольку UCRT теперь является компонентом операционной системы Microsoft Windows, она входит в состав операционной системы Windows 10 и доступна через Центр обновления Windows для старых операционных систем от Windows Vista до Windows 8.1. Because the UCRT is now a Microsoft Windows operating system component, it is included as part of the operating system in Windows 10 and is available through Windows Update for older operating systems, Windows Vista through Windows 8.1. Распространяемая версия доступна для Windows XP. A redistributable version is available for Windows XP. Как компонент операционной системы управление обновлениями и обслуживанием UCRT осуществляется с помощью Центра обновления Windows независимо от версий Visual Studio и компилятора Microsoft C++. As an operating system component, UCRT updates and servicing are managed by Windows Update independently of Visual Studio and Microsoft C++ compiler versions. Поскольку UCRT является компонентом Windows, в связи с небольшим размером образа и в целях обеспечения безопасности и простоты применения обновлений настоятельно рекомендуется выполнять централизованное развертывание UCRT для приложений. Because the UCRT is a Windows component, for security and ease of updates, and a smaller image size, we strongly recommend central deployment of the UCRT for your app.
UCRT можно использовать в любой версии Windows, поддерживаемой Visual Studio 2015 или Visual Studio 2017. You can use the UCRT on any version of Windows supported by Visual Studio 2015 or Visual Studio 2017. Ее можно распространять с помощью пакета vcredist для поддерживаемых версий Windows (кроме Windows 10). You can redistribute it using a vcredist package for supported versions of Windows other than Windows 10. Пакеты vcredist включают в себя компоненты UCRT и автоматически устанавливают их в операционных системах Windows, где они не установлены по умолчанию. The vcredist packages include the UCRT components and automatically install them on Windows operating systems that do not have them installed by default. Дополнительные сведения см. в разделе Распространение файлов Visual C++. For more information, see Redistributing Visual C++ Files.
Поддерживается развертывание локальных приложений UCRT, хотя этот вариант является нерекомендуемым по соображениям безопасности и производительности. App-local deployment of the UCRT is supported, though not recommended for both performance and security reasons. Библиотеки DLL для развертывания локальных приложений входят в состав пакета SDK Windows и находятся в подкаталоге redist. The DLLs for app-local deployment are included as part of the Windows SDK, under the redist subdirectory. Требуемые библиотеки DLL содержат ucrtbase.dll и набор библиотек DLL переадресации APISet с именем api-ms-win-subset.dll. The DLLs required include ucrtbase.dll and a set of APISet forwarder DLLs named api-ms-win-subset.dll. Для каждой операционной системы требуется разный набор библиотек DLL, поэтому при развертывании локальных приложений рекомендуется включать все библиотеки DLL. The set of DLLs required on each operating system varies, so we recommended that you include all of the DLLs when you use app-local deployment. Дополнительные сведения и советы об использовании развертываний локальных приложений см. в разделе Развертывание в Visual C++. For additional details and caveats about app-local deployment, see Deployment in Visual C++.
Изменения функций и макросов универсальной среды выполнения Changes to the Universal CRT functions and macros
Многие функции были добавлены или обновлены в UCRT для повышения соответствия стандарту ISO C99, а также для устранения проблем, связанных с качеством и безопасностью кода. Many functions were added or updated in the UCRT to improve ISO C99 conformance, and to address code quality and security issues. В некоторых случаях требовалось внести критические изменения в библиотеку. In some cases, this required breaking changes to the library. Если код компилируется правильно при использовании более ранней версии CRT, но прерывается при компиляции с использованием UCRT, необходимо изменить код, чтобы воспользоваться преимуществами этих обновлений и функций. If your code compiled cleanly when using an older version of the CRT but breaks when compiled using the UCRT, you must change your code to take advantage of these updates and features. Подробный список критических изменений и обновлений для универсальной среды выполнения в разделе Библиотека времени выполнения C (CRT) в журнале изменений Visual C++. For a detailed listing of the breaking changes and updates to the CRT found in the Universal CRT, see the C Runtime Library (CRT) section of the Visual C++ change history. В него входит перечень затронутых заголовков и функции, который можно использовать для определения изменений, необходимых для кода. It includes a list of affected headers and functions that you can use to identify the changes needed in your code.