Skip to content

Commit 387ce22

Browse files
authored
Merge pull request #3340 from MicrosoftDocs/master
12/17/2020 AM Publish
2 parents 48b8977 + 746b295 commit 387ce22

13 files changed

Lines changed: 120 additions & 71 deletions

docs/build/configure-cmake-debugging-sessions.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Configure CMake debugging sessions in Visual Studio"
33
description: "Describes how to use Visual Studio to configure CMake debugger settings."
4-
ms.date: "12/07/2020"
4+
ms.date: 12/16/2020
55
helpviewer_keywords: ["CMake debugging"]
66
---
77
# Configure CMake debugging sessions
@@ -14,7 +14,7 @@ Native CMake support is available in Visual Studio 2017 and later. To see the do
1414

1515
::: moniker range=">=msvc-150"
1616

17-
All executable CMake targets are shown in the **Startup Item** dropdown in the **General** toolbar. Select one to start a debugging session and launch the debugger.
17+
All executable CMake targets are shown in the **Startup Item** dropdown in the toolbar. Select one to start a debugging session and launch the debugger.
1818

1919
![CMake startup item dropdown](media/cmake-startup-item-dropdown.png "CMake startup item dropdown")
2020

@@ -105,8 +105,10 @@ In Visual Studio 2019 version 16.6, we added a new debug configuration of `type:
105105
#### Additional options allowed with the `gdbserver` configuration (16.7 or later)
106106

107107
- `program`: Defaults to `"${debugInfo.fullTargetPath}"`. The Unix path to the application to debug. Only required if different than the target executable in the build or deploy location.
108-
> [!TIP]
109-
> Deploy is not yet supported for local cross-compilation scenarios. If you are cross-compiling on Windows (for example, using a cross-compiler on Windows to build a Linux ARM executable) then you'll need to manually copy the binary to the location specified by `program` on the remote ARM machine before debugging.
108+
109+
> [!TIP]
110+
> Deploy is not yet supported for local cross-compilation scenarios. If you are cross-compiling on Windows (for example, using a cross-compiler on Windows to build a Linux ARM executable) then you'll need to manually copy the binary to the location specified by `program` on the remote ARM machine before debugging.
111+
110112
- `remoteMachineName`: Defaults to `"${debugInfo.remoteMachineName}"`. Name of the remote system that hosts the program to debug. Only required if different than the build system. Must have an existing entry in the [Connection Manager](../linux/connect-to-your-remote-linux-computer.md). Press **Ctrl+Space** to view a list of all existing remote connections.
111113
- `cwd`: Defaults to `"${debugInfo.defaultWorkingDirectory}"`. Full Unix path to the directory on the remote system where `program` is run. The directory must exist.
112114
- `gdbPath`: Defaults to `${debugInfo.vsInstalledGdb}`. Full Windows path to the `gdb` used to debug. Defaults to the `gdb` installed with the Linux development with C/C++ workload.

docs/c-runtime-library/format-specification-fields-scanf-and-wscanf-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: "Learn more about: Format Specification Fields: scanf and wscanf Fu
33
title: "Format Specification Fields: scanf and wscanf Functions"
44
ms.date: "11/04/2016"
55
ms.topic: "reference"
6-
ms.custom: contperfq1
6+
ms.custom: contperf-fy21q1
77
helpviewer_keywords: ["width, specifications in scanf function", "scanf format specifications", "scanf width specifications", "scanf type field characters", "type fields, scanf function", "format specification fields for scanf function", "type fields"]
88
ms.assetid: 7e95de1b-0b71-4de3-9f81-c9560c78e039
99
---

docs/code-quality/c26401.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
---
22
title: C26401
3-
ms.date: 07/21/2017
3+
ms.date: 12/14/2020
44
ms.topic: "conceptual"
55
f1_keywords: ["C26401"]
66
helpviewer_keywords: ["C26401"]
77
ms.assetid: b9d3d398-697a-4a5d-8bfe-9c667dffb90b
8-
description: CppCoreCheck rule that enforces C++ Core Guidelines I.11
8+
description: CppCoreCheck rule C26401 enforces C++ Core Guidelines I.11
99
---
1010
# C26401 DONT_DELETE_NON_OWNER
1111

12-
This check detects places where moving to `owner<T>` can be a good option for the first stage of refactoring. Like C26400 it enforces rules I.11 and R.3, but focuses on the "release" portion of the pointer lifetime. It warns on any call to operator **`delete`** if its target is neither an `owner<T>` nor an implicitly assumed owner. For more information, see [C26400](c26400.md) regarding the **`auto`** declarations. This does include expressions that refer to global variables, formals, and so on.
12+
This check detects places where moving to `owner<T>` can be a good option for the first stage of refactoring. Like C26400, it enforces rules I.11 and R.3, but focuses on the "release" portion of the pointer lifetime. It warns on any call to operator **`delete`** if its target isn't an `owner<T>` or an implicitly assumed owner. For more information about **`auto`** declarations, see [C26400](c26400.md). This check includes expressions that refer to global variables, formal parameters, and so on.
1313

14-
Warnings C26400 and C26401 always occur with [C26409](c26409.md), but they are more appropriate for scenarios where immediate migration to smart pointers is not feasible. In such cases the `owner<T>` concept can be adopted first and C26409 may be temporarily suppressed.
14+
Warnings C26400 and C26401 always occur with [C26409](c26409.md), but they're more appropriate for scenarios where immediate migration to smart pointers isn't feasible. In such cases, the `owner<T>` concept can be adopted first, and C26409 may be temporarily suppressed.
1515

1616
## See also
1717

1818
[C++ Core Guidelines I.11](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#i11-never-transfer-ownership-by-a-raw-pointer-t-or-reference-t)
1919

20-
## Example
20+
## Examples
2121

2222
```cpp
2323
struct myStruct {};
@@ -45,3 +45,25 @@ void function()
4545
delete pMyStruct; // no warning.
4646
}
4747
```
48+
49+
There's a C++ idiom, `delete this`, that triggers this warning. The warning is intentional, because the C++ Core Guidelines discourage this pattern. You can suppress the warning by using the `gsl::suppress` attribute, as shown in this example:
50+
51+
```cpp
52+
class MyReferenceCountingObject final
53+
{
54+
public:
55+
void AddRef();
56+
void Release() noexcept
57+
{
58+
ref_count_--;
59+
if (ref_count_ == 0)
60+
{
61+
[[gsl::suppress(i.11)]]
62+
delete this;
63+
}
64+
}
65+
private:
66+
unsigned int ref_count_{1};
67+
};
68+
```
69+

docs/code-quality/c26409.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
description: "Learn more about: C26409 NO_NEW_DELETE"
2+
description: "Learn more about CppCoreCheck rule C26409: avoid explicit new and delete."
33
title: C26409
4-
ms.date: 08/20/2020
4+
ms.date: 12/14/2020
55
ms.topic: "conceptual"
66
f1_keywords: ["C26409"]
77
helpviewer_keywords: ["C26409"]
@@ -11,7 +11,7 @@ ms.assetid: a3b3a229-d566-4be3-bd28-2876ccc8dc37
1111

1212
> `Avoid calling new and delete explicitly, use std::make_unique<T> instead (r.11).`
1313
14-
Even if code is clean of calls to`malloc()` and `free()`, we still suggest that you consider better options than explicit use of operators [`new` and `delete`](../cpp/new-and-delete-operators.md).
14+
Even if code is clean of calls to `malloc` and `free`, we still suggest that you consider better options than explicit use of operators [`new` and `delete`](../cpp/new-and-delete-operators.md).
1515

1616
**C++ Core Guidelines**:\
1717
[R.11: Avoid calling new and delete explicitly](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly)
@@ -22,7 +22,7 @@ The ultimate fix is to use smart pointers and appropriate factory functions, suc
2222

2323
- The checker warns on calls to any kind of operator **`new`** or **`delete`**: scalar, vector, overloaded versions (global and class-specific), and placement versions. The placement **`new`** case may require some clarifications in the Core Guidelines for suggested fixes, and may be omitted in the future.
2424

25-
## Example
25+
## Examples
2626

2727
This example shows C26409 is raised for explicit **`new`** and **`delete`**. Consider using smart pointer factory functions such as `std::make_unique` instead.
2828

@@ -35,3 +35,24 @@ void f(int i)
3535
auto unique = std::make_unique<int[]>(i); // prefer using smart pointers over new and delete
3636
}
3737
```
38+
39+
There's a C++ idiom, `delete this`, that triggers this warning. The warning is intentional, because the C++ Core Guidelines discourage this pattern. You can suppress the warning by using the `gsl::suppress` attribute, as shown in this example:
40+
41+
```cpp
42+
class MyReferenceCountingObject final
43+
{
44+
public:
45+
void AddRef();
46+
void Release() noexcept
47+
{
48+
ref_count_--;
49+
if (ref_count_ == 0)
50+
{
51+
[[gsl::suppress(i.11)]]
52+
delete this;
53+
}
54+
}
55+
private:
56+
unsigned int ref_count_{1};
57+
};
58+
```

docs/code-quality/how-to-specify-additional-code-information-by-using-analysis-assume.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
---
2-
description: "Learn more about: How to: Specify Additional Code Information by Using _Analysis_assume"
3-
title: "Use _Analysis_assume for code analysis hints"
4-
ms.date: 11/04/2016
2+
description: "Learn more about how to specify additional code information by using _Analysis_assume_."
3+
title: "Use _Analysis_assume_ for code analysis hints"
4+
ms.date: 12/16/2020
55
ms.topic: "conceptual"
66
f1_keywords:
7-
- "_Analysis_assume"
7+
- "_Analysis_assume_"
88
helpviewer_keywords:
9-
- "_Analysis_assume"
10-
ms.assetid: 51205d97-4084-4cf4-a5ed-3eeaf67deb1b
9+
- "_Analysis_assume_"
1110
---
12-
# How to: Specify Additional Code Information by Using _Analysis_assume
11+
# How to specify additional code information by using `_Analysis_assume_`
1312

14-
You can provide hints to the code analysis tool for C/C++ code that will help the analysis process and reduce warnings. To provide additional information, use the following function:
13+
You can provide hints to the code analysis tool for C/C++ code that will help the analysis process and reduce warnings. To provide additional information, use the following function macro:
1514

16-
`_Analysis_assume(` `expr` `)`
15+
`_Analysis_assume( expr )`
1716

18-
`expr` - any expression that is assumed to evaluate to true.
17+
*`expr`* - any expression that is assumed to evaluate to true.
1918

20-
The code analysis tool assumes that the condition represented by the expression is true at the point where the function appears and remains true until expression is altered, for example, by assignment to a variable.
19+
The code analysis tool assumes that the condition represented by the expression *`expr`* is true at the point where the function appears. And, it remains true until *`expr`* is altered, for example, by assignment to a variable.
2120

2221
> [!NOTE]
23-
> `_Analysis_assume` does not impact code optimization. Outside the code analysis tool, `_Analysis_assume` is defined as a no-op.
22+
> `_Analysis_assume_` does not impact code optimization. Outside the code analysis tool, `_Analysis_assume_` is defined as a no-op.
2423
2524
## Example
2625

27-
The following code uses `_Analysis_assume` to correct the code analysis warning [C6388](../code-quality/c6388.md):
26+
The following code uses `_Analysis_assume_` to correct the code analysis warning [C6388](../code-quality/c6388.md):
2827

2928
```cpp
30-
#include<windows.h>
31-
#include<codeanalysis\sourceannotations.h>
29+
#include <windows.h>
30+
#include <codeanalysis\sourceannotations.h>
3231

3332
using namespace vc_attributes;
3433

@@ -42,7 +41,7 @@ void test()
4241
{
4342
char pc = (char)malloc(5);
4443
FreeAndNull(&pc);
45-
_Analysis_assume(pc == NULL);
44+
_Analysis_assume_(pc == NULL);
4645
f(pc);
4746
}
4847
```

docs/code-quality/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
href: ../code-quality/intrinsic-functions.md
3939
- name: Best practices and examples (SAL)
4040
href: ../code-quality/best-practices-and-examples-sal.md
41-
- name: Specify additional code information by using _Analysis_assume
41+
- name: Specify additional code information by using _Analysis_assume_
4242
href: ../code-quality/how-to-specify-additional-code-information-by-using-analysis-assume.md
4343
- name: C++ Core Guidelines checker warnings
4444
items:

docs/code-quality/using-the-cpp-core-guidelines-checkers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Using the C++ Core Guidelines checkers
33
description: "How to set up and use the Microsoft C++ Code Analysis rules for C++ Core Guidelines."
4-
ms.date: 07/27/2020
4+
ms.date: 12/16/2020
55
ms.topic: "conceptual"
66
dev_langs:
77
- CPP
@@ -297,13 +297,13 @@ Code Analysis requires a few environment variables and compiler command-line opt
297297
- `set esp.annotationbuildlevel=ignore` This disables the logic that processes SAL annotations. Annotations don't affect code analysis in the C++ Core Guidelines Checker, yet their processing takes time (sometimes a long time). This setting is optional, but highly recommended.
298298
- `set caexcludepath=%include%` We highly recommend that you disable warnings that fire on standard headers. You can add more paths here, for example the path to the common headers in your project.
299299

300-
- **Command line options**
300+
- **Command-line options**
301301
- **`/analyze`** Enables code analysis (consider also using **`/analyze:only`** and **`/analyze:quiet`**).
302302
- **`/analyze:plugin EspXEngine.dll`** This option loads the Code Analysis Extensions engine into the PREfast. This engine, in turn, loads the C++ Core Guidelines Checker.
303303

304304
## Use the Guideline Support Library
305305

306-
The Guideline Support Library (GSL) is designed to help you follow the Core Guidelines. The GSL includes definitions that let you replace error-prone constructs with safer alternatives. For example, you can replace a `T*, length` pair of parameters with the `span<T>` type. The GSL is available at [http://www.nuget.org/packages/Microsoft.Gsl](https://www.nuget.org/packages/Microsoft.Gsl). The library is open-source, so you can view the sources, make comments, or contribute. The project can be found at [https://github.com/Microsoft/GSL](https://github.com/Microsoft/GSL).
306+
The Guideline Support Library (GSL) is designed to help you follow the Core Guidelines. The GSL includes definitions that let you replace error-prone constructs with safer alternatives. For example, you can replace a `T*, length` pair of parameters with the `span<T>` type. The GSL project is available on GitHub at [https://github.com/Microsoft/GSL](https://github.com/Microsoft/GSL). The library is open-source, so you can view the sources, make comments, or contribute. You can also use the [vcpkg](../build/vcpkg.md) package manager to download and install the library locally.
307307

308308
::: moniker range="msvc-140"
309309

docs/cpp/main-function-command-line-args.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "`main` function and command-line arguments (C++)"
33
description: "The `main` function is the entry point for a C++ program."
4-
ms.date: 11/19/2020
4+
ms.date: 12/16/2020
55
no-loc: [main, wmain, inline, static, _tmain, void, exit, argc, argv, envp, CreateProcess, GetModuleFileName, char, wchar_t, extern]
66
---
77
# `main` function and command-line arguments
@@ -88,19 +88,21 @@ The following example shows how to use the *`argc`*, *`argv`*, and *`envp`* argu
8888
#include <string.h>
8989
9090
using namespace std;
91-
int main( int argc, char *argv[], char *envp[] ) {
92-
int iNumberLines = 0; // Default is no line numbers.
91+
int main( int argc, char *argv[], char *envp[] )
92+
{
93+
bool numberLines = false; // Default is no line numbers.
9394
9495
// If /n is passed to the .exe, display numbered listing
9596
// of environment variables.
96-
9797
if ( (argc == 2) && _stricmp( argv[1], "/n" ) == 0 )
98-
iNumberLines = 1;
98+
numberLines = true;
9999
100100
// Walk through list of strings until a NULL is encountered.
101-
for( int i = 0; envp[i] != NULL; ++i ) {
102-
if( iNumberLines )
103-
cout << i << ": " << envp[i] << "\n";
101+
for ( int i = 0; envp[i] != NULL; ++i )
102+
{
103+
if ( numberLines )
104+
cout << i << ": "; // Prefix with numbers if /n specified
105+
cout << envp[i] << "\n";
104106
}
105107
}
106108
```

0 commit comments

Comments
 (0)