diff --git a/docs/build/cmake-presets-vs.md b/docs/build/cmake-presets-vs.md index 0939cc7d88e..f14c59a8c6d 100644 --- a/docs/build/cmake-presets-vs.md +++ b/docs/build/cmake-presets-vs.md @@ -1,7 +1,7 @@ --- title: Configure and build with CMake Presets description: "Reference for using CMake Presets to configure and build CMake projects." -ms.date: 04/07/2022 +ms.date: 09/13/2022 ms.topic: reference --- @@ -21,9 +21,9 @@ We recommend *`CMakePresets.json`* as an alternative to *`CMakeSettings.json`*. ## Supported CMake and *`CMakePresets.json`* versions -Visual Studio supports version 2 or later for the *`CMakePresets.json`* and *`CMakeUserPresets.json`* files. You can update your file version by incrementing the version field in the root object. For an example and more information, see [`CMakePresets.json` format](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#format). +The supported *`CMakePresets.json`* and *`CMakeUserPresets.json`* schema versions depend on your version of Visual Studio. Visual Studio 2019 version 16.10 and later support schema versions 2 and 3. Visual Studio 2022 version 17.4 preview 2 adds support for schema versions 4 and 5. You can update the version by changing the `"version"` field in the root object. For an example and more information, see [`CMakePresets.json` format](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#format). -CMake version 3.20 or later is required when you're invoking CMake with *`CMakePresets.json`* (version 2 or later) from the command line. However, Visual Studio reads and evaluates *`CMakePresets.json`* and *`CMakeUserPresets.json`* itself and doesn't invoke CMake directly with the `--preset` option. So, CMake version 3.20 or later isn't strictly required when you're building with *`CMakePresets.json`* inside Visual Studio. We recommend using CMake version 3.14 or later. +CMake version 3.20 or later is required when you're invoking CMake with *`CMakePresets.json`* from the command line. However, Visual Studio reads and evaluates *`CMakePresets.json`* and *`CMakeUserPresets.json`* itself and doesn't invoke CMake directly with the `--preset` option. So, CMake version 3.20 or later isn't strictly required when you're building with *`CMakePresets.json`* inside Visual Studio. We recommend using at least CMake version 3.14 or later. ## Enable *`CMakePresets.json`* integration in Visual Studio diff --git a/docs/c-runtime-library/reference/getch-getwch.md b/docs/c-runtime-library/reference/getch-getwch.md index 5a143906bf1..9bbf456b338 100644 --- a/docs/c-runtime-library/reference/getch-getwch.md +++ b/docs/c-runtime-library/reference/getch-getwch.md @@ -8,7 +8,6 @@ api_type: ["DLLExport"] topic_type: ["apiref"] f1_keywords: ["getwch", "_getch", "_getwch"] helpviewer_keywords: ["characters, getting from console", "getch function", "_getwch function", "console, reading from", "_getch function", "getwch function"] -ms.assetid: cc116be7-cff2-4274-970f-5e7b18ccc05c --- # `_getch`, `_getwch` @@ -30,9 +29,9 @@ Returns the character read. There's no error return. ## Remarks -The **`_getch`** and **`_getwch`** functions read a single character from the console without echoing the character. None of these functions can be used to read CTRL+C. When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code. +The **`_getch`** and **`_getwch`** functions read a single character from the console without echoing the character. None of these functions can be used to read CTRL+C. To read a function key or arrow key, each function must be called twice. The first call returns `0` or `0xE0`. The second call returns the [key scan code](/previous-versions/visualstudio/visual-studio-6.0/aa299374(v=vs.60)). -These functions lock the calling thread and are therefore thread-safe. For non-locking versions, see [`_getch_nolock`, `_getwch_nolock`](getch-nolock-getwch-nolock.md). +These functions lock the calling thread and so are thread-safe. For non-locking versions, see [`_getch_nolock`, `_getwch_nolock`](getch-nolock-getwch-nolock.md). By default, this function's global state is scoped to the application. To change this, see [Global state in the CRT](../global-state.md). @@ -89,8 +88,8 @@ Type 'Y' when finished typing keys: Y ## See also -[Console and Port I/O](../../c-runtime-library/console-and-port-i-o.md)
-[`_getche`, `_getwche`](getche-getwche.md)
-[`_cgets`, `_cgetws`](../../c-runtime-library/cgets-cgetws.md)
-[`getc`, `getwc`](getc-getwc.md)
-[`_ungetch`, `_ungetwch`, `_ungetch_nolock`, `_ungetwch_nolock`](ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md)
+[Console and Port I/O](../../c-runtime-library/console-and-port-i-o.md)\ +[`_getche`, `_getwche`](getche-getwche.md)\ +[`_cgets`, `_cgetws`](../../c-runtime-library/cgets-cgetws.md)\ +[`getc`, `getwc`](getc-getwc.md)\ +[`_ungetch`, `_ungetwch`, `_ungetch_nolock`, `_ungetwch_nolock`](ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md) diff --git a/docs/code-quality/c26495.md b/docs/code-quality/c26495.md index 40152b8b05a..bab8db24eb5 100644 --- a/docs/code-quality/c26495.md +++ b/docs/code-quality/c26495.md @@ -1,21 +1,25 @@ --- title: C26495 -ms.date: 05/23/2022 +ms.date: 08/18/2022 ms.topic: reference -f1_keywords: ["C26495"] +f1_keywords: ["C26495", "MEMBER_UNINIT", "__WARNING_MEMBER_UNINIT"] helpviewer_keywords: ["C26495"] description: CppCoreCheck rule that enforces C++ Core Guidelines Type.6 --- -# C26495 MEMBER_UNINIT +# Warning C26495 -> Variable '*identifier*' is uninitialized. Always initialize a member variable (type.6). +> Variable '\**parameter-name*' is uninitialized. Always initialize a member variable (type.6). ## Remarks A member variable isn't initialized by a constructor or by an initializer. Make sure all variables are initialized by the end of construction. For more information, see C++ Core Guidelines [Type.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-type) and [C.48](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers). +Code analysis name: MEMBER_UNINIT + ## Example +The following sample generates warning C26495 because the member variable `value` isn't initialized when a `MyStruct` object is created. + ```cpp struct MyStruct { @@ -24,12 +28,12 @@ struct MyStruct }; ``` -To fix the warning, add in-class initialization to all of the member variables: +To resolve the issue, you can add in-class initialization to all of the member variables. ```cpp struct MyStruct { - int value{}; + int value{}; // empty brace initializer sets value to 0 MyStruct() {} // no warning, MyStruct::value is set via default member initialization }; ``` diff --git a/docs/code-quality/c6101.md b/docs/code-quality/c6101.md index 6294816d293..76bb0c863ca 100644 --- a/docs/code-quality/c6101.md +++ b/docs/code-quality/c6101.md @@ -1,14 +1,39 @@ --- description: "Learn more about: C6101" title: C6101 -ms.date: 11/04/2016 +ms.date: 08/17/2022 ms.topic: reference -f1_keywords: ["C6101"] +f1_keywords: ["C6101", "RETURN_UNINIT_VAR", "__WARNING_RETURN_UNINIT_VAR"] helpviewer_keywords: ["C6101"] ms.assetid: 8546367c-5de5-479a-a231-c15c0aa89ef1 --- -# C6101 +# Warning C6101 -> warning C6101: Returning uninitialized memory +> Returning uninitialized memory '\**parameter-name*'. A successful path through the function does not set the named \_Out\_ parameter. -A successful path through the function does not set the named `_Out_` parameter. This message is generated based on SAL annotations that indicate that the function in question always succeeds. A function that doesn't return a success/failure indication should set all of its `_Out_` parameters because the analyzer assumes that the `_Out_` parameter is uninitialized data before the function is called, and that the function will set the parameter so that it's no longer uninitialized. If the function does indicate success/failure, then the `_Out_` parameter doesn't have to be set in the case of failure, and you can detect and avoid the uninitialized location. In either case, the objective is to avoid the reading of an uninitialized location. If the function sometimes doesn't touch an `_Out_` parameter that's subsequently used, then the parameter should be initialized before the function call and be marked with the `_Inout_` annotation, or the more explicit `_Pre_null_` or `_Pre_satisfies_()` when appropriate. "Partial success" can be handled with the `_When_` annotation. For more information, see [Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md). +## Remarks + +This message is generated based on SAL annotations that indicate that the function in question always succeeds. A function that doesn't return a success/failure indication should set all of its `_Out_` parameters because the analyzer assumes that the `_Out_` parameter is uninitialized data before the function is called, and that the function will set the parameter so that it's no longer uninitialized. If, however, the function does indicate success/failure and failure occurs, then the `_Out_` parameter doesn't have to be set. You can then detect and avoid the uninitialized location. In either case, the objective is to avoid the reading of an uninitialized location. If the function sometimes doesn't touch an `_Out_` parameter that's later used, then the parameter should be initialized before the function call and be marked with the `_Inout_` annotation, or the more explicit `_Pre_null_` or `_Pre_satisfies_()` when appropriate. "Partial success" can be handled with the `_When_` annotation. For more information, see [Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md). + +Code analysis name: RETURN_UNINIT_VAR + +## Example + +The following code generates this warning. This issue stems from the pointer p1 not being set despite having been annotated with `_Out_`. + +```cpp +void example_func(_Out_ int *p1) +{ + return; +} +``` + +To resolve the issue, you can set the value of the parameter. Or, if the value is always initialized before the function is called, change the SAL annotation to `_Inout_`. By setting the value of the parameter, the following code avoids the warning: + +```cpp +void example_func(_Out_ int *p1) +{ + *p1 = 1; + return; +} +``` diff --git a/docs/get-started/includes/git-source-control.md b/docs/get-started/includes/git-source-control.md index 86a7efc76a0..c1d17bec684 100644 --- a/docs/get-started/includes/git-source-control.md +++ b/docs/get-started/includes/git-source-control.md @@ -20,7 +20,7 @@ To associate your code with Git, you start by creating a new Git repository wher 1. In the **Create a Git repository** dialog box, sign in to GitHub. - :::image type="content" source="../media/vs-2022/git-create-repo.png" alt-text="Screenshot of the Create a Git Repository dialog window where you can sign in to GitHub."::: + :::image type="content" source="../media/vs-2022/git-create-repo.png" alt-text="Screenshot of the Create a Git Repository dialog window where you create a new GitHub repository."::: The repository name auto-populates based on your folder location. By default, your new repository is private, which means you're the only one who can access it. @@ -29,9 +29,9 @@ To associate your code with Git, you start by creating a new Git repository wher 1. Select **Create and Push**. - After you create your repository, you see status details in the status bar. + After you create your repository, status details appear in the status bar. - :::image type="content" source="../media/vs-2022/git-new-private-repo-status-details.png" alt-text="Screenshot of the repo status bar that's below the Solution Explorer pane in Visual Studio."::: + :::image type="content" source="../media/vs-2022/git-new-private-repo-status-details.png" alt-text="Screenshot of the repo status bar located below the Visual Studio Solution Explorer pane, showing the branch name and number of outstanding changes."::: The first icon with the arrows shows how many outgoing/incoming commits are in your current branch. You can use this icon to pull any incoming commits or push any outgoing commits. You can also choose to view these commits first. To do so, select the icon, and then select **View Outgoing/Incoming**. diff --git a/docs/get-started/tutorial-console-cpp.md b/docs/get-started/tutorial-console-cpp.md index 0383f331c2e..0658bad4de9 100644 --- a/docs/get-started/tutorial-console-cpp.md +++ b/docs/get-started/tutorial-console-cpp.md @@ -5,7 +5,6 @@ ms.custom: "acquisition, mvc" ms.date: 08/31/2021 ms.topic: "tutorial" ms.devlang: "cpp" -ms.assetid: 45138d70-719d-42dc-90d7-1d0ca31a2f54 --- # Create a console calculator in C++ @@ -23,20 +22,20 @@ Visual Studio uses *projects* to organize the code for an app, and *solutions* t 1. If you've just started Visual Studio, you'll see the Visual Studio Start dialog box. Choose **Create a new project** to get started. - ![Screenshot of the Visual Studio 2022 initial dialog.](./media/calc-vs2022-initial-dialog.png) + ![Screenshot of the Visual Studio 2022 initial dialog with options such as create a new project, open an existing project, and more.](./media/calc-vs2022-initial-dialog.png) Otherwise, on the menubar in Visual Studio, choose **File** > **New** > **Project**. The **Create a new project** window opens. 1. In the list of project templates, choose **Console App**, then choose **Next**. - ![Screenshot of choosing the Console App template.](./media/calc-vs2019-choose-console-app.png "Choose the Console App template") + ![Screenshot of the Create a new project dialog, with the Console App template selected.](./media/calc-vs2019-choose-console-app.png "Choose the Console App template") > [!Important] > Make sure you choose the C++ version of the **Console App** template. It has the **C++**, **Windows**, and **Console** tags, and the icon has "++" in the corner. 1. In the **Configure your new project** dialog box, select the **Project name** edit box, name your new project *CalculatorTutorial*, then choose **Create**. - ![Name your project in the Configure your new project dialog.](./media/calc-vs2019-name-your-project.png "Name your project in the Configure your new project dialog") + ![Screenshot of the Configure your new project dialog, which has fields for the project name, project location, and so on.](./media/calc-vs2019-name-your-project.png "Name your project in the Configure your new project dialog") An empty C++ Windows console application gets created. Console applications use a Windows console window to display output and accept user input. In Visual Studio, an editor window opens and shows the generated code: @@ -69,11 +68,11 @@ The template for a new Windows console application creates a simple C++ "Hello W 1. To build your project, choose **Build Solution** from the **Build** menu. The **Output** window shows the results of the build process. - ![Screenshot of Visual Studio 2019 with the Output window showing the result of the build process.](./media/calc-vs2019-build-your-project.png "Build the project") + ![Screenshot of the Visual Studio Output window showing the result of the build.](./media/calc-vs2019-build-your-project.png "Build the project") 1. To run the code, on the menu bar, choose **Debug**, **Start without debugging**. - ![Screenshot of the Visual Studio 2019 Microsoft Visual Studio Debug Console showing the code ran successfully.](./media/calc-vs2019-hello-world-console.png "Start the project") + ![Screenshot of the Visual Studio Debug Console showing the output: "Hello World!"](./media/calc-vs2019-hello-world-console.png "Run the project") A console window opens and then runs your app. When you start a console app in Visual Studio, it runs your code, then prints "Press any key to close this window . . ." to give you a chance to see the output. Congratulations! You've created your first "Hello, world!" console app in Visual Studio! @@ -85,7 +84,7 @@ You now have the tools to build and run your app after every change, to verify t Now let's turn the code in this template into a calculator app. -1. In the *CalculatorTutorial.cpp* file, edit the code to match this example: +1. In the *`CalculatorTutorial.cpp`* file, edit the code to match this example: ```cpp // CalculatorTutorial.cpp : This file contains the 'main' function. Program execution begins and ends there. @@ -142,9 +141,9 @@ It's time to add some math logic. ![Screenshot of the Visual Studio 2019 Solution Explorer window displaying the Calculator Tutorial project.](./media/calc-vs2019-solution-explorer.png "Solution Explorer") - You should now have three tabs open in the editor: *CalculatorTutorial.cpp*, *Calculator.h*, and *Calculator.cpp*. If you accidentally close one of them, you can reopen it by double-clicking it in the **Solution Explorer** window. + You should now have three tabs open in the editor: *`CalculatorTutorial.cpp`*, *`Calculator.h`*, and *`Calculator.cpp`*. If you accidentally close one of them, you can reopen it by double-clicking it in the **Solution Explorer** window. -1. In **Calculator.h**, remove the `Calculator();` and `~Calculator();` lines that were generated, since you won't need them here. Next, add the following line of code so the file now looks like this: +1. In **`Calculator.h`**, remove the `Calculator();` and `~Calculator();` lines that were generated, since you won't need them here. Next, add the following line of code so the file now looks like this: ```cpp #pragma once @@ -162,17 +161,17 @@ It's time to add some math logic. > - The two lines you deleted declared a *constructor* and *destructor* for the class. For a simple class like this one, the compiler creates them for you, and their uses are beyond the scope of this tutorial. > - It's good practice to organize your code into different files based on what it does, so it's easy to find the code you need later. In our case, we define the `Calculator` class separately from the file containing the `main()` function, but we plan to reference the `Calculator` class in `main()`. -1. You'll see a green squiggle appear under `Calculate`. It's because we haven't defined the `Calculate` function in the .cpp file. Hover over the word, click the lightbulb (in this case, a screwdriver) that pops up, and choose **Create definition of 'Calculate' in Calculator.cpp**. +1. You'll see a green squiggle appear under `Calculate`. It's because we haven't defined the `Calculate` function in the .cpp file. Hover over the word, click the lightbulb (in this case, a screwdriver) that pops up, and choose **Create definition of 'Calculate' in `Calculator.cpp`**. - ![Screenshot of Visual Studio 2019 showing the Create definition of Calculate in Calculator C P P option highlighted.](./media/calc-vs2019-create-definition.png "Create definition of Calculate") + ![Screenshot of Visual Studio showing a tool tip dropdown with Create definition of Calculate in Calculator C P P highlighted.](./media/calc-vs2019-create-definition.png "Create definition of Calculate") - A pop-up appears that gives you a peek of the code change that was made in the other file. The code was added to *Calculator.cpp*. + A pop-up appears that gives you a peek of the code change that was made in the other file. The code was added to *`Calculator.cpp`*. - ![Pop-up with definition of Calculate.](./media/calc-vs2019-pop-up-definition.png "Pop-up with definition of Calculate") + !["Screenshot of a pop-up displaying the definition of Calculate."](./media/calc-vs2019-pop-up-definition.png) Currently, it just returns 0.0. Let's change that. Press **Esc** to close the pop-up. -1. Switch to the *Calculator.cpp* file in the editor window. Remove the `Calculator()` and `~Calculator()` sections (as you did in the .h file) and add the following code to `Calculate()`: +1. Switch to the *`Calculator.cpp`* file in the editor window. Remove the `Calculator()` and `~Calculator()` sections (as you did in the .h file) and add the following code to `Calculate()`: ```cpp #include "Calculator.h" @@ -206,7 +205,7 @@ If you build and run the code again at this point, it will still exit after aski ### To call the Calculator class member functions -1. Now let's update the `main` function in *CalculatorTutorial.cpp*: +1. Now let's update the `main` function in *`CalculatorTutorial.cpp`*: ```cpp // CalculatorTutorial.cpp : This file contains the 'main' function. Program execution begins and ends there. @@ -258,7 +257,7 @@ Now it's time to test the program again to make sure everything works properly. 1. Enter `5 + 5`, and press **Enter**. Verify that the result is 10. - ![Screenshot of the Visual Studio 2019 Microsoft Visual Studio Debug Console showing the correct result of 5 + 5.](./media/calc-vs2019-five-plus-five.png "The result of 5 + 5") + ![Screenshot of the Visual Studio Debug Console showing the correct result of 5 + 5.](./media/calc-vs2019-five-plus-five.png "The result of 5 + 5") ## Debug the app @@ -268,29 +267,29 @@ Since the user is free to type anything into the console window, let's make sure 1. Set a breakpoint on the `result = c.Calculate(x, oper, y);` line, just after the user was asked for input. To set the breakpoint, click next to the line in the gray vertical bar along the left edge of the editor window. A red dot appears. - ![Screenshot of Visual Studio 2019 showing the red dot that represents a breakpoint.](./media/calc-vs2019-set-breakpoint.png "Set a breakpoint") + ![Screenshot of Visual Studio with a red dot to the left of a line of code, representing a breakpoint.](./media/calc-vs2019-set-breakpoint.png "Set a breakpoint") Now when we debug the program, it always pauses execution at that line. We already have a rough idea that the program works for simple cases. Since we don't want to pause execution every time, let's make the breakpoint conditional. 1. Right-click the red dot that represents the breakpoint, and choose **Conditions**. In the edit box for the condition, enter `(y == 0) && (oper == '/')`. Choose the **Close** button when you're done. The condition is saved automatically. - ![Screenshot of Visual Studio 2019 showing the Breakpoint Settings section and a condition added to the Is true value.](./media/calc-vs2019-conditional-breakpoint.png "Set a conditional breakpoint") + ![Screenshot of Visual Studio showing the Breakpoint Settings pop up and the condition y==0 && oper == '/' for the Is true value.](./media/calc-vs2019-conditional-breakpoint.png "Set a conditional breakpoint") Now we pause execution at the breakpoint specifically if a division by 0 is attempted. 1. To debug the program, press **F5**, or choose the **Local Windows Debugger** toolbar button that has the green arrow icon. In your console app, if you enter something like "5 - 0", the program behaves normally and keeps running. However, if you type "10 / 0", it pauses at the breakpoint. You can even put any number of spaces between the operator and numbers: `cin` is smart enough to parse the input appropriately. - ![Screenshot of Visual Studios 2019 showing that the program paused at the conditional breakpoint.](./media/calc-vs2019-debug-breakpoint.png "Pause at the conditional breakpoint") + ![Screenshot of Visual Studio showing the program paused at the conditional breakpoint.](./media/calc-vs2019-debug-breakpoint.png "Pause at the conditional breakpoint") ### Useful windows in the debugger Whenever you debug your code, you may notice that some new windows appear. These windows can assist your debugging experience. Take a look at the **Autos** window. The **Autos** window shows you the current values of variables used at least three lines before and up to the current line. To see all of the variables from that function, switch to the **Locals** window. You can actually modify the values of these variables while debugging, to see what effect they would have on the program. In this case, we'll leave them alone. - ![Screenshot of the Locals window in Visual Studio 2019.](./media/calc-vs2019-debug-locals.png "The Locals window") + ![Screenshot of the Visual Studio Locals window showing the values of local variables.](./media/calc-vs2019-debug-locals.png "The Locals window") You can also just hover over variables in the code itself to see their current values where the execution is currently paused. Make sure the editor window is in focus by clicking on it first. - ![Screenshot of Visual Studio 2019 showing the tooltip that appears displaying the value of the variable.](./media/calc-vs2019-hover-tooltip.png "Hover to view current variable values") + ![Screenshot of a tooltip displaying the value of the variable oper, which is the character `/`.](./media/calc-vs2019-hover-tooltip.png "Hover to view current variable values") ### To continue debugging @@ -302,7 +301,7 @@ You can also just hover over variables in the code itself to see their current v It looks like the program is doing what is expected: it takes the first number, and divides it by the second. On the `cout` line, hover over the `result` variable or take a look at `result` in the **Autos** window. You'll see its value is listed as "inf", which doesn't look right, so let's fix it. The `cout` line just outputs whatever value is stored in `result`, so when you step one more line forward using **F10**, the console window displays: - ![Screenshot of the Visual Studio 2019 Microsoft Visual Studio Debug Console showing the result of dividing by zero.](./media/calc-vs2019-divide-by-zero-fail.png "The result of divide by zero") + ![Screenshot of the Visual Studio Debug Console showing the result of dividing by zero, which is inf.](./media/calc-vs2019-divide-by-zero-fail.png "The result of divide by zero") This result happens because division by zero is undefined, so the program doesn't have a numerical answer to the requested operation. @@ -310,7 +309,7 @@ You can also just hover over variables in the code itself to see their current v Let's handle division by zero more gracefully, so a user can understand the problem. -1. Make the following changes in *CalculatorTutorial.cpp*. (You can leave the program running as you edit, thanks to a debugger feature called **Edit and Continue**): +1. Make the following changes in *`CalculatorTutorial.cpp`*. (You can leave the program running as you edit, thanks to a debugger feature called **Edit and Continue**): ```cpp // CalculatorTutorial.cpp : This file contains the 'main' function. Program execution begins and ends there. @@ -353,7 +352,9 @@ Let's handle division by zero more gracefully, so a user can understand the prob 1. Now press **F5** once. Program execution continues all the way until it has to pause to ask for user input. Enter `10 / 0` again. Now, a more helpful message is printed. The user is asked for more input, and the program continues executing normally. - ![Screenshot of the Visual Studio 2019 Microsoft Visual Studio Debug Console showing the final result after changes.](./media/calc-vs2019-final-verification.png "The final result after changes") + :::image type="complex" source="./media/calc-vs2019-final-verification.png" alt-text="Screenshot of the Visual Studio Debug Console showing the final result after changes"::: + The console window displays two lines: 10 / 0 Result is: inf, followed by, 10 / 0 Division by 0 exception. + :::image-end::: > [!Note] > When you edit code while in debugging mode, there is a risk of code becoming stale. This happens when the debugger is still running your old code, and has not yet updated it with your changes. The debugger pops up a dialog to inform you when this happens. Sometimes, you may need to press **F5** to refresh the code being executed. In particular, if you make a change inside a function while the point of execution is inside that function, you'll need to step out of the function, then back into it again to get the updated code. If that doesn't work for some reason and you see an error message, you can stop debugging by clicking on the red square in the toolbar under the menus at the top of the IDE, then start debugging again by entering **F5** or by choosing the green "play" arrow beside the stop button on the toolbar. @@ -399,7 +400,7 @@ Visual Studio uses *projects* to organize the code for an app, and *solutions* t 3. In the **Name** edit box at the bottom, name the new project *CalculatorTutorial*, then choose **OK**. - ![The New Project dialog.](./media/calculator-new-project-dialog.png "The New Project dialog") + ![Screenshot of the New Project dialog with the Windows Console Application project type selected and the Name text box set to CalculatorTutorial.](./media/calculator-new-project-dialog.png "The New Project dialog") An empty C++ Windows console application gets created. Console applications use a Windows console window to display output and accept user input. In Visual Studio, an editor window opens and shows the generated code: @@ -433,11 +434,11 @@ The template for a new windows console application creates a simple C++ "Hello W 1. To build your project, choose **Build Solution** from the **Build** menu. The **Output** window shows the results of the build process. - ![Screenshot Visual Studio with the Output window showing the result of the build process.](./media/calculator-initial-build-output.png "Build the project") + ![Screenshot of the Visual Studio Output window showing that the build was successful.](./media/calculator-initial-build-output.png "Build the project") 1. To run the code, on the menu bar, choose **Debug**, **Start without debugging**. - ![Screenshot of the Microsoft Visual Studio Debug Console showing the code ran successfully.](./media/calculator-hello-world-console.png "Start the project") + ![Screenshot of the Visual Studio Debug Console showing the output: Hello World!.](./media/calculator-hello-world-console.png "Start the project") A console window opens and then runs your app. When you start a console app in Visual Studio, it runs your code, then prints "Press any key to continue . . ." to give you a chance to see the output. Congratulations! You've created your first "Hello, world!" console app in Visual Studio! @@ -449,7 +450,7 @@ You now have the tools to build and run your app after every change, to verify t Now let's turn the code in this template into a calculator app. -1. In the *CalculatorTutorial.cpp* file, edit the code to match this example: +1. In the *`CalculatorTutorial.cpp`* file, edit the code to match this example: ```cpp // CalculatorTutorial.cpp : This file contains the 'main' function. Program execution begins and ends there. @@ -492,7 +493,9 @@ Now let's turn the code in this template into a calculator app. 1. To run the application, press **Ctrl+F5** or go to the **Debug** menu and choose **Start Without Debugging**. If you get a pop-up that says **This project is out of date**, you may select **Do not show this dialog again**, and then choose **Yes** to build your application. You should see a console window appear that displays the text specified in the code. - ![Build and start your application.](./media/calculator-first-launch.gif "Build and start your application") + :::image type="complex" source="./media/calculator-first-launch.gif" alt-text="Short video of running the calculator app."::: + Short video showing Debug > Start without debugging. A dialog is visible that asks whether to build because the project is out of date. The checkbox for 'Do not show this dialog again' is selected. 'Yes' is selected to build the project, the calculator project builds, and then launches in a Windows console window. + :::image-end::: 1. Close the console window when you're done. @@ -510,9 +513,9 @@ It's time to add some math logic. ![Screenshot of the Solution Explorer window displaying the Calculator Tutorial project.](./media/calculator-solution-explorer.png "Solution Explorer") - You should now have three tabs open in the editor: *CalculatorTutorial.cpp*, *Calculator.h*, and *Calculator.cpp*. If you accidentally close one of them, you can reopen it by double-clicking it in the **Solution Explorer** window. + You should now have three tabs open in the editor: *`CalculatorTutorial.cpp`*, *`Calculator.h`*, and *`Calculator.cpp`*. If you accidentally close one of them, you can reopen it by double-clicking it in the **Solution Explorer** window. -1. In **Calculator.h**, remove the `Calculator();` and `~Calculator();` lines that were generated, since you won't need them here. Next, add the following line of code so the file now looks like this: +1. In **`Calculator.h`**, remove the `Calculator();` and `~Calculator();` lines that were generated, since you won't need them here. Next, add the following line of code so the file now looks like this: ```cpp #pragma once @@ -530,13 +533,13 @@ It's time to add some math logic. > - The two lines you deleted declared a *constructor* and *destructor* for the class. For a simple class like this one, the compiler creates them for you, and their uses are beyond the scope of this tutorial. > - It's good practice to organize your code into different files based on what it does, so it's easy to find the code you need later. In our case, we define the `Calculator` class separately from the file containing the `main()` function, but we plan to reference the `Calculator` class in `main()`. -1. You'll see a green squiggle appear under `Calculate`. It's because we haven't defined the `Calculate` function in the .cpp file. Hover over the word, click the lightbulb that pops up, and choose **Create definition of 'Calculate' in Calculator.cpp**. A pop-up appears that gives you a peek of the code change that was made in the other file. The code was added to *Calculator.cpp*. +1. You'll see a green squiggle appear under `Calculate`. It's because we haven't defined the `Calculate` function in the .cpp file. Hover over the word, click the lightbulb that pops up, and choose **Create definition of 'Calculate' in `Calculator.cpp`**. A pop-up appears that gives you a peek of the code change that was made in the other file. The code was added to *`Calculator.cpp`*. ![Short video showing the user selecting the Create definition of Calculate in Calculator C P P option.](./media/calculator-create-definition.gif "Create definition of Calculate") Currently, it just returns 0.0. Let's change that. Press **Esc** to close the pop-up. -1. Switch to the *Calculator.cpp* file in the editor window. Remove the `Calculator()` and `~Calculator()` sections (as you did in the .h file) and add the following code to `Calculate()`: +1. Switch to the *`Calculator.cpp`* file in the editor window. Remove the `Calculator()` and `~Calculator()` sections (as you did in the .h file) and add the following code to `Calculate()`: ```cpp #include "pch.h" @@ -571,7 +574,7 @@ If you build and run the code again at this point, it will still exit after aski ### To call the Calculator class member functions -1. Now let's update the `main` function in *CalculatorTutorial.cpp*: +1. Now let's update the `main` function in *`CalculatorTutorial.cpp`*: ```cpp // CalculatorTutorial.cpp : This file contains the 'main' function. Program execution begins and ends there. @@ -634,33 +637,35 @@ Since the user is free to type anything into the console window, let's make sure 1. Set a breakpoint on the `result = c.Calculate(x, oper, y);` line, just after the user was asked for input. To set the breakpoint, click next to the line in the gray vertical bar along the left edge of the editor window. A red dot appears. - ![Short video of Visual Studios showing the user creating the red dot that represents a breakpoint.](./media/calculator-set-breakpoint.gif "Set a breakpoint") + ![Short video of Visual Studio showing the user setting a breakpoint which creates a red dot to the left of the line of code.](./media/calculator-set-breakpoint.gif "Set a breakpoint") Now when we debug the program, it always pauses execution at that line. We already have a rough idea that the program works for simple cases. Since we don't want to pause execution every time, let's make the breakpoint conditional. 1. Right-click the red dot that represents the breakpoint, and choose **Conditions**. In the edit box for the condition, enter `(y == 0) && (oper == '/')`. Choose the **Close** button when you're done. The condition is saved automatically. - ![Short video of Visual Studio 2019 showing the user opening the Breakpoint Settings section and setting a conditional breakpoint.](./media/calculator-conditional-breakpoint.gif "Set a conditional breakpoint") + :::image type="complex" source="./media/calculator-conditional-breakpoint.gif" alt-text="Set a conditional breakpoint"::: + Short video showing a right-click on the breakpoint. The breakpoint is on the line of code that reads result = c dot Calculate ( x, oper, y). 'Conditions...' is selected in the dropdown which opens the breakpoint settings window. In the text box following the Conditional Expression and Is true dropdowns, the user enters y == 0 && oper == '/', and then selects close to set the conditional breakpoint. + :::image-end::: Now we pause execution at the breakpoint specifically if a division by 0 is attempted. 1. To debug the program, press **F5**, or choose the **Local Windows Debugger** toolbar button that has the green arrow icon. In your console app, if you enter something like "5 - 0", the program behaves normally and keeps running. However, if you type "10 / 0", it pauses at the breakpoint. You can even put any number of spaces between the operator and numbers; `cin` is smart enough to parse the input appropriately. - ![Short video of Visual Studios showing that the program paused at the conditional breakpoint.](./media/calculator-debug-conditional.gif "Pause at the conditional breakpoint") + ![Short video showing the program paused at the conditional breakpoint.](./media/calculator-debug-conditional.gif "Pause at the conditional breakpoint") ### Useful windows in the debugger Whenever you debug your code, you may notice that some new windows appear. These windows can assist your debugging experience. Take a look at the **Autos** window. The **Autos** window shows you the current values of variables used at least three lines before and up to the current line. - ![The Autos window.](./media/calculator-autos.png "The Autos window") + ![Screenshot of the Autos window showing the values of c, oper, result, x, and y.](./media/calculator-autos.png "The Autos window") To see all of the variables from that function, switch to the **Locals** window. You can actually modify the values of these variables while debugging, to see what effect they would have on the program. In this case, we'll leave them alone. - ![Screenshot of the Locals window.](./media/calculator-locals.png "The Locals window") + ![Screenshot of the Locals window showing the values of the function's local variables.](./media/calculator-locals.png "The Locals window") You can also just hover over variables in the code itself to see their current values where the execution is currently paused. Make sure the editor window is in focus by clicking on it first. - ![Short video showing the tooltip that appears displaying the value of the variable.](./media/calculator-hover-tooltip.gif "Hover to view current variable values") + ![Short video showing the tooltip that appears when you hover over a variable. The tooltip displays the variable's value.](./media/calculator-hover-tooltip.gif "Hover to view current variable values") ### To continue debugging @@ -670,11 +675,11 @@ You can also just hover over variables in the code itself to see their current v 1. Continue using **F10** to **Step Over** each line until you get back to the `main()` function in the other file, and stop on the `cout` line. - ![Step out of Calculate and check result.](./media/calculator-undefined-zero.gif "Step out of Calculate and check result") + ![Short video of stepping over lines in the Calculate function until back in main(). Then hovering over the result variable and seeing its value: inf.](./media/calculator-undefined-zero.gif "Step out of Calculate and check result") It looks like the program is doing what is expected: it takes the first number, and divides it by the second. On the `cout` line, hover over the `result` variable or take a look at `result` in the **Autos** window. You'll see its value is listed as "inf", which doesn't look right, so let's fix it. The `cout` line just outputs whatever value is stored in `result`, so when you step one more line forward using **F10**, the console window displays: - ![Screenshot of the Microsoft Visual Studio Debug Console showing the result of dividing by zero.](./media/calculator-divide-by-zero-fail.png "The result of divide by zero") + ![Screenshot of the Visual Studio Debug Console which shows the result of dividing by zero: inf](./media/calculator-divide-by-zero-fail.png "The result of divide by zero") This result happens because division by zero is undefined, so the program doesn't have a numerical answer to the requested operation. @@ -682,7 +687,7 @@ You can also just hover over variables in the code itself to see their current v Let's handle division by zero more gracefully, so a user can understand the problem. -1. Make the following changes in *CalculatorTutorial.cpp*. (You can leave the program running as you edit, thanks to a debugger feature called **Edit and Continue**): +1. Make the following changes in *`CalculatorTutorial.cpp`*. (You can leave the program running as you edit, thanks to a debugger feature called **Edit and Continue**): ```cpp // CalculatorTutorial.cpp : This file contains the 'main' function. Program execution begins and ends there. @@ -726,7 +731,7 @@ Let's handle division by zero more gracefully, so a user can understand the prob 1. Now press **F5** once. Program execution continues all the way until it has to pause to ask for user input. Enter `10 / 0` again. Now, a more helpful message is printed. The user is asked for more input, and the program continues executing normally. - ![Short video of the Microsoft Visual Studio Debug Console showing the final result after changes.](./media/calculator-final-verification.gif "The final result after changes") + ![Short video of the Debug Console which shows the final result after changes. 10 / 0 is entered and the program displays: Division by 0 exception.](./media/calculator-final-verification.gif "The final result after changes") > [!Note] > When you edit code while in debugging mode, there is a risk of code becoming stale. This happens when the debugger is still running your old code, and has not yet updated it with your changes. The debugger pops up a dialog to inform you when this happens. Sometimes, you may need to press **F5** to refresh the code being executed. In particular, if you make a change inside a function while the point of execution is inside that function, you'll need to step out of the function, then back into it again to get the updated code. If that doesn't work for some reason and you see an error message, you can stop debugging by clicking on the red square in the toolbar under the menus at the top of the IDE, then start debugging again by entering **F5** or by choosing the green "play" arrow beside the stop button on the toolbar. diff --git a/docs/linux/cmake-linux-configure.md b/docs/linux/cmake-linux-configure.md index e2badf94a20..c25b94031e9 100644 --- a/docs/linux/cmake-linux-configure.md +++ b/docs/linux/cmake-linux-configure.md @@ -108,7 +108,7 @@ When you do a build: ## Choose a Linux target -When you open a CMake project folder, Visual Studio parses the *CMakeLists.txt* file and specifies a Windows target of **x86-Debug**. To target a remote Linux system, you'll change the project settings based on your Linux compiler. For example, if you're using GCC on Linux and compiling with debug info, choose: **Linux-GCC-Debug** or **Linux-GCC-Release**. +When you open a CMake project folder, Visual Studio parses the *CMakeLists.txt* file, and specifies a Windows target of **x86-Debug**. To target a remote Linux system, you'll change the project settings based on your Linux compiler. For example, if you're using GCC on Linux and compiling with debug info, choose: **Linux-GCC-Debug** or **Linux-GCC-Release**. If you specify a remote Linux target, your source is copied to the remote system. @@ -125,11 +125,11 @@ If you're targeting Windows Subsystem for Linux (WSL), you don't need to add a r To target WSL, select **Manage Configurations** in the configuration dropdown in the main toolbar: -![CMake Manage Configurations.](../build/media/vs2019-cmake-manage-configurations.png "CMake configurations drop-down") +![CMake configurations drop-down with Manage Configurations selected](../build/media/vs2019-cmake-manage-configurations.png "CMake configurations drop-down") The **CMakeSettings.json** window appears. -![Add configuration.](media/cmake-linux-configurations.png "Add a configuration to CMake settings") +![CMake settings dialog with the plus button highlighted which adds the selected configuration, which is Linux-GCC-debug.](media/cmake-linux-configurations.png ) Press **Add Configuration** (the green '+' button) and then choose **Linux-GCC-Debug** or **Linux-GCC-Release** if using GCC. Use the Clang variants if you're using the Clang/LLVM toolset. Press **Select** and then **Ctrl+S** to save the configuration. diff --git a/docs/linux/connect-to-your-remote-linux-computer.md b/docs/linux/connect-to-your-remote-linux-computer.md index 2199001c80e..64bf1780f08 100644 --- a/docs/linux/connect-to-your-remote-linux-computer.md +++ b/docs/linux/connect-to-your-remote-linux-computer.md @@ -64,11 +64,11 @@ If `ssh` isn't already set up and running on your Linux system, follow these ste 1. In the Connection Manager dialog, choose the **Add** button to add a new connection. - ![Screenshot showing the Connection Manager dialog.](media/settings_connectionmanager.png) + ![Screenshot showing the options pane and CrossPlatform > C plus plus > Connection Manager selected. The Add button is highlighted.](media/settings_connectionmanager.png) In either scenario, the **Connect to Remote System** window is displayed. - ![Screenshot showing the Connect to Remote System window.](media/connect.png) + ![Screenshot showing the Connect to Remote System window which has fields for host name, port, user name, authentication type, and password.](media/connect.png) 1. Enter the following information: @@ -90,7 +90,7 @@ If `ssh` isn't already set up and running on your Linux system, follow these ste If the connection fails, the entry boxes that need to be changed are outlined in red. - ![Screenshot showing a Connection Manager Error.](media/settings_connectionmanagererror.png) + ![Screenshot of the Connect to Remote System window with the host name and port fields outlined in red to indicate that they are incorrect.](media/settings_connectionmanagererror.png) If you use key files for authentication, make sure the target machine's SSH server is running and configured properly. @@ -181,7 +181,7 @@ For example: `HostKeyAlgorithms ssh-dss,ssh-rsa` You can enable logging to help troubleshoot connection problems. On the menu bar, select **Tools > Options**. In the **Options** dialog, select **Cross Platform > Logging**: - ![Screenshot showing Remote Logging.](media/remote-logging-vs2019.png) + ![Screenshot of the Remote Logging screen with options to enable logging, log file location, and whether to log to the output window.](media/remote-logging-vs2019.png) Logs include connections, all commands sent to the remote machine (their text, exit code and execution time), and all output from Visual Studio to the shell. Logging works for any cross-platform CMake project or MSBuild-based Linux project in Visual Studio. @@ -199,13 +199,11 @@ For example: `HostKeyAlgorithms ssh-dss,ssh-rsa` The `rsync` command is used by both MSBuild-based Linux projects and CMake projects to [copy headers from your remote system to Windows for use by IntelliSense](configure-a-linux-project.md#remote_intellisense). When you can't enable TCP port forwarding, disable the automatic download of remote headers. To disable it, use **Tools > Options > Cross Platform > Connection Manager > Remote Headers IntelliSense Manager**. If the remote system doesn't have TCP port forwarding enabled, you'll see this error when the download of remote headers for IntelliSense begins: -![Screenshot showing a Headers Error.](media/port-forwarding-headers-error.png) - - +![Screenshot showing an error that the SSH channel couldn't be opened, and a path to log file for more details.](media/port-forwarding-headers-error.png) `rsync` is also used by Visual Studio's CMake support to copy source files to the remote system. If you can't enable TCP port forwarding, you can use `sftp` as your remote copy sources method. `sftp` is often slower than `rsync`, but doesn't have a dependency on TCP port forwarding. You can manage your remote copy sources method with the `remoteCopySourcesMethod` property in the [CMake Settings Editor](../build/cmakesettings-reference.md#settings-for-cmake-linux). If TCP port forwarding is disabled on your remote system, you'll see an error in the CMake output window the first time it invokes `rsync`. -![Screenshot showing an Rsync Error.](media/port-forwarding-copy-error.png) +![Screenshot of the output window which shows an Rsync Error that the SSH channel couldn't be opened.](media/port-forwarding-copy-error.png) `gdbserver` can be used for debugging on embedded devices. If you can't enable TCP port forwarding, then you must use `gdb` for all remote debugging scenarios. `gdb` is used by default when debugging projects on a remote system. diff --git a/docs/linux/create-a-new-linux-project.md b/docs/linux/create-a-new-linux-project.md index d2d98e79f44..7002e23eefd 100644 --- a/docs/linux/create-a-new-linux-project.md +++ b/docs/linux/create-a-new-linux-project.md @@ -2,7 +2,6 @@ title: "Create a Linux MSBuild C++ project in Visual Studio" ms.date: "10/15/2020" description: "Create a new MSBuild-based Linux project in Visual Studio." -ms.assetid: 5d7c1d67-bc31-4f96-8622-2b4cf91372fd --- # Create a Linux MSBuild C++ project in Visual Studio @@ -25,7 +24,7 @@ To create a new Linux project in Visual Studio 2017, follow these steps: 1. Select **File > New Project** in Visual Studio, or press **Ctrl + Shift + N**. 1. Select the **Visual C++ > Cross Platform > Linux** node, and then select the project type to create. Enter a **Name** and **Location**, and choose **OK**. - ![Screenshot showing the New Project dialog box with Visual C plus plus > Cross Platform > Linux selected, all of the project types called out, and the Name and Location text boxes also called out.](media/newproject.png) +![The New Project dialog box with Visual C plus plus > Cross Platform > Linux selected and all project types and Name and Location text boxes called out.](media/newproject.png) | Project Type | Description | | ------------ | --- | @@ -52,7 +51,7 @@ To create a new Linux project in Visual Studio, follow these steps: 1. In the **Search for templates** textbox, enter **Linux** to list the available templates for Linux projects. 1. Select the project type to create, for example **Console Application**, and then choose **Next**. Enter a **Name** and **Location**, and choose **Create**. - ![Screenshot of the new project dialog box with the language drop-down set to C++ and the platform drop-down set to Linux.](media/newproject-vs2019.png) + ![Screenshot of the new project dialog box with the language drop-down set to C plus plus and the platform drop-down set to Linux.](media/newproject-vs2019.png) | Project Type | Description | | ------------ | --- | diff --git a/docs/linux/deploy-run-and-debug-your-linux-project.md b/docs/linux/deploy-run-and-debug-your-linux-project.md index e7911b3e5bc..33d57455ee8 100644 --- a/docs/linux/deploy-run-and-debug-your-linux-project.md +++ b/docs/linux/deploy-run-and-debug-your-linux-project.md @@ -2,7 +2,6 @@ title: "Deploy, run, and debug your Linux MSBuild C++ project in Visual Studio" description: "Describes how to compile, execute, and debug code on the remote target from inside a MSBuild-based Linux C++ project in Visual Studio." ms.date: "08/08/2020" -ms.assetid: f7084cdb-17b1-4960-b522-f84981bea879 ms.custom: intro-deployment --- # Deploy, run, and debug your Linux MSBuild project @@ -56,11 +55,11 @@ There are several ways to interact with and debug your Linux project. When the remote target is available, you'll see it listed by either name or IP address. - ![Screenshot showing a Remote target.](media/remote_target.png) + ![Screenshot showing a Remote target IP address.](media/remote_target.png) If you haven't connected to the remote target yet, you'll see an instruction to use [Linux Connection Manager](connect-to-your-remote-linux-computer.md) to connect to the remote target. - ![Screenshot showing the Remote Architecture.](media/architecture.png) + ![Screenshot showing the Remote Architecture, which is x64.](media/architecture.png) 1. Set a breakpoint by clicking in the left gutter of some code that you know will execute. @@ -99,7 +98,7 @@ There are several ways to interact with and debug your Linux project. ## Debug with Attach to Process -The [Debugging](prop-pages/debugging-linux.md) property page for Visual Studio projects, and the **Launch.vs.json** settings for CMake projects, have settings that enable you to attach to a running process. If you require additional control beyond what is provided in those settings, you can place a file named `Microsoft.MIEngine.Options.xml` in the root of your solution or workspace. Here is a simple example: +The [Debugging](prop-pages/debugging-linux.md) property page for Visual Studio projects, and the **Launch.vs.json** settings for CMake projects, have settings that enable you to attach to a running process. If you require more control beyond what is provided in those settings, you can place a file named `Microsoft.MIEngine.Options.xml` in the root of your solution or workspace. Here is a simple example: ```xml @@ -116,7 +115,7 @@ ExePath="C:\temp\ConsoleApplication17\ConsoleApplication17\bin\x64\Debug\Console ``` -The **AttachOptionsForConnection** has most of the attributes you might need. The example above shows how to specify a location to search for additional .so libraries. The child element **ServerOptions** enables attaching to the remote process with gdbserver instead. To do that, you need to specify a local gdb client (the one shipped in Visual Studio 2017 is shown above) and a local copy of the binary with symbols. The **SetupCommands** element enables you to pass commands directly to gdb. You can find all the options available in the [LaunchOptions.xsd schema](https://github.com/Microsoft/MIEngine/blob/master/src/MICore/LaunchOptions.xsd) on GitHub. +The **AttachOptionsForConnection** has most of the attributes you might need. The example above shows how to specify a location to search for more .so libraries. The child element **ServerOptions** enables attaching to the remote process with gdbserver instead. To do that, you need to specify a local gdb client (the one shipped in Visual Studio 2017 is shown above) and a local copy of the binary with symbols. The **SetupCommands** element enables you to pass commands directly to gdb. You can find all the options available in the [LaunchOptions.xsd schema](https://github.com/Microsoft/MIEngine/blob/master/src/MICore/LaunchOptions.xsd) on GitHub. ::: moniker range=">=msvc-160" @@ -126,13 +125,13 @@ You can separate your remote build machine from your remote debug machine for bo By default, the remote debug machine is the same as the remote build machine (**Configuration Properties** > **General** > **Remote Build Machine**). To specify a new remote debug machine, right-click on the project in **Solution Explorer** and go to **Configuration Properties** > **Debugging** > **Remote Debug Machine**. -![Screenshot showing the Linux remote debug machine property in the Property Pages dialog.](media/linux-remote-debug-machine.png) +![Screenshot showing the Linux remote debug machine property in the Property Pages dialog which shows the username, authentication type, and port.](media/linux-remote-debug-machine.png) The drop-down menu for **Remote Debug Machine** is populated with all established remote connections. To add a new remote connection, navigate to **Tools** > **Options** > **Cross Platform** > **Connection Manager** or search for "Connection Manager" in **Quick Launch**. You can also specify a new remote deploy directory in the project's Property Pages (**Configuration Properties** > **General** > **Remote Deploy Directory**). By default, only the files necessary for the process to debug will be deployed to the remote debug machine. You can use **Solution Explorer** to configure which source files will be deployed to the remote debug machine. When you click on a source file, you'll see a preview of its File Properties directly below the Solution Explorer. -![Screenshot showing the Linux deployable files specified in the Properties window.](media/linux-deployable-content.png) +![Screenshot showing the properties of the file main.cpp with the property content = False highlighted.](media/linux-deployable-content.png) The **Content** property specifies whether the file will be deployed to the remote debug machine. You can disable deployment entirely by navigating to **Property Pages** > **Configuration Manager** and unchecking **Deploy** for the desired configuration. @@ -159,7 +158,7 @@ In some cases, you may require more control over your project's deployment. For For CMake projects that target a remote Linux machine, you can specify a new remote debug machine in launch.vs.json. By default, the value of "remoteMachineName" is synchronized with the "remoteMachineName" property in CMakeSettings.json, which corresponds to your remote build machine. These properties no longer need to match, and the value of "remoteMachineName" in launch.vs.json will dictate which remote machine is used for deploy and debug. -![The CMake remote debug machine specified in the launch.vs.json file.](media/cmake-remote-debug-machine.png) +![The CMake remote debug machine specified in the launch_schema.json file. The remote Machine Name is ${debugInfo . remoteMachineName}](media/cmake-remote-debug-machine.png) IntelliSense will suggest all a list of all established remote connections. You can add a new remote connection by navigating to **Tools** > **Options** > **Cross Platform** > **Connection Manager** or searching for "Connection Manager" in **Quick Launch**. diff --git a/docs/linux/download-install-and-setup-the-linux-development-workload.md b/docs/linux/download-install-and-setup-the-linux-development-workload.md index 102bfca8ada..62e7cb3d002 100644 --- a/docs/linux/download-install-and-setup-the-linux-development-workload.md +++ b/docs/linux/download-install-and-setup-the-linux-development-workload.md @@ -2,7 +2,6 @@ title: "Install the C++ Linux workload in Visual Studio" description: "How to download, install, and set up the Linux workload for C++ in Visual Studio." ms.date: "05/03/2020" -ms.assetid: e11b40b2-f3a4-4f06-b788-73334d58dfd9 ms.custom: intro-installation --- # Download, install, and set up the Linux workload @@ -29,11 +28,11 @@ For any of these scenarios, the **Linux development with C++** workload is requi 1. Type "Visual Studio Installer" in the Windows search box: - ![Screenshot showing the Windows search box.](media/visual-studio-installer-search.png) + ![Screenshot of the Windows search box which contains the text: `visual studio installer`.](media/visual-studio-installer-search.png) 1. Look for the installer under the **Apps** results and double-click it. When the installer opens, choose **Modify**, and then click on the **Workloads** tab. Scroll down to **Other toolsets** and select the **Linux development with C++** workload. - ![Screenshot showing the Visual C++ for Linux Development workload item in Visual Studio Installer.](media/linuxworkload.png) + ![Screenshot highlighting the Visual C++ for Linux Development workload item in Visual Studio Installer.](media/linuxworkload.png) 1. If you're targeting IoT or embedded platforms, go to the **Installation details** pane on the right. Under **Linux development with C++**, expand **Optional Components**, and choose the components you need. CMake support for Linux is selected by default. diff --git a/docs/linux/linux-asan-configuration.md b/docs/linux/linux-asan-configuration.md index 127ad261d92..115a3a94c12 100644 --- a/docs/linux/linux-asan-configuration.md +++ b/docs/linux/linux-asan-configuration.md @@ -20,7 +20,7 @@ ASan is a runtime memory error detector for C/C++ that catches the following err When ASan detects an error, it stops execution immediately. If you run an ASan-enabled program in the debugger, you see a message that describes the type of error, the memory address, and the location in the source file where the error occurred: - ![Screenshot showing an ASan error message.](media/asan-error.png) + ![Screenshot showing the address sanitizer error message: heap use after free.](media/asan-error.png) You can also view the full ASan output (including where the corrupted memory was allocated/deallocated) in the Debug pane of the output window. @@ -31,26 +31,26 @@ You can also view the full ASan output (including where the corrupted memory was To enable ASan for MSBuild-based Linux projects, right-click on the project in **Solution Explorer** and select **Properties**. Next, navigate to **Configuration Properties** > **C/C++** > **Sanitizers**. ASan is enabled via compiler and linker flags, and requires your project to be recompiled to work. -![Enable ASan for an MSBuild project.](media/msbuild-asan-prop-page.png) +![Screenshot of the project property page with Configuration Properties > C/C plus plus > Sanitizers selected. Enable Address Sanitizer is set to Yes.](media/msbuild-asan-prop-page.png) You can pass optional ASan runtime flags by navigating to **Configuration Properties** > **Debugging** > **AddressSanitizer Runtime Flags**. Click the down-arrow to add or remove flags. -![Configure ASan runtime flags.](media/msbuild-asan-runtime-flags.png) +![Screenshot of the project property page with Configuration Properties > Debugging selected. Address Sanitizer Runtime Flags is `detect_leaks = 0`.](media/msbuild-asan-runtime-flags.png) ## Enable ASan for Visual Studio CMake projects > [!NOTE] > To build with CMake Presets, first enable ASan in your CMakeLists.txt file. For more information, see [Enable AddressSanitizer for Windows and Linux](../build/cmake-presets-vs.md#enable-addresssanitizer-for-windows-and-linux). -To enable ASan for CMake, right-click on the CMakeLists.txt file in **Solution Explorer** and choose **CMake Settings for Project**. +To enable ASan for CMake, right-click on the `CMakeLists.txt` file in **Solution Explorer** and choose **CMake Settings for Project**. Make sure you have a Linux configuration (for example, **Linux-Debug**) selected in the left pane of the dialog: -![Screenshot of the left pane with Linux Debug listed as one of the Configuration options.](media/linux-debug-configuration.png) +![Screenshot of the Configurations pane with x64-Debug and Linux Debug listed as the options.](media/linux-debug-configuration.png) The ASan options are under **General**. Enter the ASan runtime flags in the format "flag=value", separated by spaces. The UI incorrectly suggests using semi-colons. Use spaces or colons to separate flags. -![Screenshot of the Enable Address Sanitizer option showing some Address Sanitizer run time flags.](media/cmake-settings-asan-options.png) +![Screenshot of the Enable Address Sanitizer option showing some Address Sanitizer run time flags like detect_leaks=0.](media/cmake-settings-asan-options.png) ## Install the ASan debug symbols diff --git a/docs/linux/set-up-fips-compliant-secure-remote-linux-development.md b/docs/linux/set-up-fips-compliant-secure-remote-linux-development.md index 30133c622a8..51f07639a85 100644 --- a/docs/linux/set-up-fips-compliant-secure-remote-linux-development.md +++ b/docs/linux/set-up-fips-compliant-secure-remote-linux-development.md @@ -99,11 +99,11 @@ You've successfully set up `ssh`, created and deployed encryption keys, and test 1. In the Connection Manager dialog, choose the **Add** button to add a new connection. - ![Screenshot showing the Connection Manager dialog.](media/settings_connectionmanager.png) + ![Screenshot showing the options pane in the Connection Manager dialog. Cross Platform > C plus plus > Connection Manager is highlighted.](media/settings_connectionmanager.png) The **Connect to Remote System** window is displayed. - ![Screenshot showing the Connect to Remote System window.](media/connect.png) + ![Screenshot showing the Connect to Remote System window, which has text boxes for the host name, port, user name, auth type, and password.](media/connect.png) 1. In the **Connect to Remote System** dialog, enter the connection details of your remote machine. @@ -124,7 +124,7 @@ You've successfully set up `ssh`, created and deployed encryption keys, and test If the connection fails, the entry boxes that need to be changed are outlined in red. - ![Screenshot showing a Connection Manager Error.](media/settings_connectionmanagererror.png) + ![Screenshot of the Connect to Remote System window which has host name and port text boxes outlined in red to indicate they need to be changed.](media/settings_connectionmanagererror.png) For more information on troubleshooting your connection, see [Connect to your remote Linux computer](connect-to-your-remote-linux-computer.md).