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.
- 
+ 
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**.
- 
+ 
> [!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**.
- 
+ 
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.
- 
+ 
1. To run the code, on the menu bar, choose **Debug**, **Start without debugging**.
- 
+ 
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.

- 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`**.
- 
+ 
- 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`*.
- 
+ 
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.
- 
+ 
## 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.
- 
+ 
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.
- 
+ 
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.
- 
+ 
### 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.
- 
+ 
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.
- 
+ 
### 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:
- 
+ 
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.
- 
+ :::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**.
- 
+ 
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.
- 
+ 
1. To run the code, on the menu bar, choose **Debug**, **Start without debugging**.
- 
+ 
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.
- 
+ :::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.

- 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`*.

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.
- 
+ 
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.
- 
+ :::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.
- 
+ 
### 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.
- 
+ 
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.
- 
+ 
### 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.
- 
+ 
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:
- 
+ 
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.
- 
+ 
> [!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:
-
+
The **CMakeSettings.json** window appears.
-
+
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.
- 
+ 
In either scenario, the **Connect to Remote System** window is displayed.
- 
+ 
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.
- 
+ 
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**:
- 
+ 
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:
-
-
-
+
`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`.
-
+
`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**.
- 
+
| 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**.
- 
+ 
| 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.
- 
+ 
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.
- 
+ 
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**.
-
+
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.
-
+
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.
-
+
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:
- 
+ 
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.
- 
+ 
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:
- 
+ 
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.
-
+
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.
-
+
## 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:
-
+
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.
-
+
## 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.
- 
+ 
The **Connect to Remote System** window is displayed.
- 
+ 
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.
- 
+ 
For more information on troubleshooting your connection, see [Connect to your remote Linux computer](connect-to-your-remote-linux-computer.md).