Saturday, October 23, 2021

Case Study 4: Porting legacy Visual C++ projects

Visual Studio 2008 Sample project : wordpad

  1. Visual Studio C++ Samples
  2. Samples for Visual Studio C++ are available on the web. Microsoft has produced many C++ samples that demonstrate different functionalities across multiple technologies. Here are a few of the places to find additional samples:.

    Code Conformance

  3. C++ Conformance improvements, behavior changes, and bug fixes in Visual Studio 2017
  4. Microsoft C/C++ in Visual Studio (MSVC) makes conformance improvements and bug fixes in every release. This article lists the improvements by major release, then by version. To jump directly to the changes for a specific version, use list below In this article.

    This document lists the changes in Visual Studio 2017. For a guide to the changes in Visual Studio 2019, see C++ conformance improvements in Visual Studio 2019. For a complete list of previous conformance improvements, see Visual C++ What's New 2003 through 2015..

  5. C++ Conformance improvements, behavior changes, and bug fixes in Visual Studio 2019
  6. Microsoft C/C++ in Visual Studio (MSVC) makes conformance improvements and bug fixes in every release. This article lists the improvements by major release, then by version. To jump directly to the changes for a specific version, use the list below In this article.

    This document lists the changes in Visual Studio 2019. For a guide to the changes in Visual Studio 2017, see C++ conformance improvements in Visual Studio 2017. For a complete list of previous conformance improvements, see Visual C++ What's New 2003 through 2015..

  7. Microsoft C/C++ language conformance by Visual Studio version
  8. Standards conformance for the Microsoft C/C++ compiler in Visual Studio (MSVC) is a work in progress. Here's a summary of our ISO Standard C and C++ language and library conformance by Visual Studio version. Each C++ compiler and standard library feature name links to the ISO Standard C++ proposal paper that describes the feature, if one is available at publication time. The Supported column lists the Visual Studio version in which support for the feature first appeared.

    For details on conformance improvements, see C++ conformance improvements in Visual Studio. For a list of other changes, see What's New for Visual C++ in Visual Studio. For conformance changes in earlier versions, see Visual C++ change history and Visual C++ What's New 2003 through 2015. For current news from the C++ team, visit the C++ team blog..

    Porting an Upgrading Guide

  9. Microsoft C++ porting and upgrading guide
  10. This article provides a guide for upgrading Microsoft C++ code to the latest version of Visual Studio. For projects created in Visual Studio 2010 through 2017, just open the project in Visual Studio 2019. You can upgrade a Visual Studio 2008 or earlier project in two steps. Use Visual Studio 2010 to convert the project to MSBuild format first. Then open the project in Visual Studio 2019. For complete instructions, see Upgrading C++ projects from earlier versions of Visual Studio.

    The toolsets in Visual Studio 2015, Visual Studio 2017, and Visual Studio 2019 are binary-compatible. Now you can upgrade to a more recent version of the compiler without having to upgrade your library dependencies. For more information, see C++ binary compatibility 2015-2019...

  11. Visual Studio IDE tools for upgrading C++ code
  12. Visual Studio helps you upgrade legacy C++ code with compiler options, code analysis warnings, and editor features such as Quick Fixes, Quick Info, and the enhanced scroll bar. The term "legacy code" refers to any of these categories:

    1. Code that was formerly allowed by the Microsoft C++ compiler (MSVC) but never conformed to the C++ standard.
      To upgrade older non-conforming MSVC code, turn on the /permissive- compiler option. All instances of non-conforming usages are underlined with red squiggles in the code editor. The error messages in the Error List window include a recommendation for how to fix the error. Click on the error code to go to its help page in the documentation. If fixing all the errors at once is impractical, you can upgrade non-conforming code in stages by turning on the /permissive- option, fixing some errors, then turning the option off again. The code will compile with the new improvements, and you can go back and fix the remaining issues at a later time. See the /permissive- page for examples of non-conforming MSVC code.
    2. Code that was permitted in an earlier version of the C++ standard but has been deprecated or removed in a later version.
      To upgrade to a newer language standard, set the C++ Language Standard option to the desired standard and fix any compile errors that are raised. In general, we recommend setting the language standard to /std:c++17 or /std:c++20. The errors raised when upgrading to a newer standard are not related to the errors raised when using the /permissive- option.
    3. Code that conforms to all versions of the standard but is no longer considered best practice in modern C++.
    To identify code where changes are recommended, run Code analysis..

  13. Upgrade C++ projects from earlier versions of Visual Studio
  14. To upgrade a project created in an earlier version of Visual Studio, just open the project in the latest version of Visual Studio. Visual Studio offers to upgrade the project to the current schema.

    If you choose No, the project doesn't get upgraded. For projects created in Visual Studio 2010 and later, you can still use the project in the newer version of Visual Studio. Just set your project properties to continue to target the older toolset. If you leave the older version of Visual Studio on your computer, its toolset is available in later versions. For example, if your project must continue to run on Windows XP, you can upgrade to Visual Studio 2019. You then specify the toolset as v141_xp or earlier in your project properties. For more information, see Use native multi-targeting in Visual Studio to build old projects.

    If you choose Yes, then the project gets upgraded in place. It can't be converted back to the earlier version. In upgrade scenarios, that's why it's good practice to make a backup copy of the existing project and solution files...

  15. Porting and Upgrading: Examples and Case Studies
  16. You can get an idea of the kinds of issues you might encounter duration a migration from a previous version of Visual C++ to the current one by reviewing stories of successful migrations.

  17. Overview of potential upgrade issues (Visual C++)
  18. Over the years, the Microsoft C++ compiler has undergone many changes, along with changes in the C++ language itself, the C++ Standard Library, the C runtime (CRT), and other libraries such as MFC and ATL. As a result, when upgrading an application from an earlier version of Visual Studio you might encounter compiler and linker errors and warnings in code that previously compiled cleanly. The older the original code base, the greater the potential for such errors. This overview summarizes the most common classes of issues you are likely to encounter, and provides links to more detailed information.

  19. C++ binary compatibility between Visual Studio 2015, 2017, and 2019
  20. The Microsoft C++ (MSVC) compiler toolsets in Visual Studio 2013 and earlier don't guarantee binary compatibility across major versions. You can't link object files, static libraries, dynamic libraries, and executables built by different versions of these toolsets. The ABIs, object formats, and runtime libraries are incompatible.

    We've changed this behavior in Visual Studio 2015, 2017, and 2019. The runtime libraries and apps compiled by any of these versions of the compiler are binary-compatible. It's reflected in the C++ toolset major number, which starts with 14 for all three versions. (The toolset version is v140 for Visual Studio 2015, v141 for 2017, and v142 for 2019). Say you have third-party libraries built by Visual Studio 2015. You can still use them in an application built by Visual Studio 2017 or 2019. There's no need to recompile with a matching toolset. The latest version of the Microsoft Visual C++ Redistributable package (the Redistributable) works for all of them..

    Code Samples

  21. Porting Guide: Spy++
  22. This porting case study is designed to give you an idea of what a typical porting project is like, the types of problems you might encounter, and some general tips and tricks for addressing porting problems. It's not meant to be a definitive guide to porting, since the experience of porting a project depends very much on the specifics of the code.

  23. Porting Guide: MFC Scribble
  24. This topic is the first of several topics that introduce you to the upgrade procedure for Visual Studio C++ projects that were created in older versions of Visual Studio to Visual Studio 2017. These topics introduce the upgrade process by example, starting with a very simple project and moving to slightly more complex ones. In this topic, we work through the upgrade process for a specific project, MFC Scribble. It is suitable as a basic introduction to the upgrade process for C++ projects.

    Each version of Visual Studio introduces possible incompatibilities that can complicate moving code from an older version of Visual Studio to a newer one. Sometimes the required changes are in your code, so you must recompile and update your code, and sometimes the required changes are to the project files. When you open a project that was created with a previous version of Visual Studio, Visual Studio automatically asks you whether to update a project or solution to the latest version. These tools usually upgrade only the project files; they do not modify your source code..

No comments:

Post a Comment