Skip to content

Commit b745efd

Browse files
author
Colin Robertson
authored
Address cpp-docs issues 2620, 2622, 2636, 2645, 2654, 2658, 2661, and more (MicrosoftDocs#3338)
* Misc. fixes for cpp-docs issues * Add fix for 2658 * Update for 2636, 2645, 2620, 2622
1 parent f68fd5e commit b745efd

9 files changed

Lines changed: 65 additions & 59 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/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/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
```

docs/cpp/writing-an-exception-filter.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
2-
description: "Learn more about: Writing an exception filter"
2+
description: "Learn more about how to write a structured exception filter."
33
title: "Writing an exception filter"
4-
ms.date: "11/04/2016"
4+
ms.date: 12/16/2020
55
helpviewer_keywords: ["exception handling [C++], filters"]
6-
ms.assetid: 47fc832b-a707-4422-b60a-aaefe14189e5
76
---
87
# Writing an exception filter
98

10-
You can handle an exception either by jumping to the level of the exception handler or by continuing execution. Instead of using the exception handler code to handle the exception and falling through, you can use *filter* to clean up the problem and then, by returning -1, resume normal flow without clearing the stack.
9+
You can handle an exception either by jumping to the level of the exception handler or by continuing execution. Instead of using the exception handler code to handle the exception and falling through, you can use a *filter* expression to clean up the problem. Then, by returning `EXCEPTION_CONTINUE_EXECUTION` (-1), you may resume normal flow without clearing the stack.
1110

1211
> [!NOTE]
13-
> Some exceptions cannot be continued. If *filter* evaluates to -1 for such an exception, the system raises a new exception. When you call [RaiseException](/windows/win32/api/errhandlingapi/nf-errhandlingapi-raiseexception), you determine whether the exception will continue.
12+
> Some exceptions cannot be continued. If *filter* evaluates to -1 for such an exception, the system raises a new exception. When you call [`RaiseException`](/windows/win32/api/errhandlingapi/nf-errhandlingapi-raiseexception), you determine whether the exception will continue.
1413
1514
For example, the following code uses a function call in the *filter* expression: this function handles the problem and then returns -1 to resume normal flow of control:
1615

@@ -39,19 +38,19 @@ int Eval_Exception ( int n_except ) {
3938
}
4039
```
4140
42-
It is a good idea to use a function call in the *filter* expression whenever *filter* needs to do anything complex. Evaluating the expression causes execution of the function, in this case, `Eval_Exception`.
41+
It's a good idea to use a function call in the *filter* expression whenever *filter* needs to do anything complex. Evaluating the expression causes execution of the function, in this case, `Eval_Exception`.
4342
44-
Note the use of [GetExceptionCode](/windows/win32/Debug/getexceptioncode) to determine the exception. You must call this function inside the filter itself. `Eval_Exception` cannot call `GetExceptionCode`, but it must have the exception code passed to it.
43+
Note the use of [`GetExceptionCode`](/windows/win32/Debug/getexceptioncode) to determine the exception. This function must be called inside the filter expression of the **`__except`** statement. `Eval_Exception` can't call `GetExceptionCode`, but it must have the exception code passed to it.
4544
46-
This handler passes control to another handler unless the exception is an integer or floating-point overflow. If it is, the handler calls a function (`ResetVars` is only an example, not an API function) to reset some global variables. *Statement-block-2*, which in this example is empty, can never be executed because `Eval_Exception` never returns EXCEPTION_EXECUTE_HANDLER (1).
45+
This handler passes control to another handler unless the exception is an integer or floating-point overflow. If it is, the handler calls a function (`ResetVars` is only an example, not an API function) to reset some global variables. The **`__except`** statement block, which in this example is empty, can never be executed because `Eval_Exception` never returns `EXCEPTION_EXECUTE_HANDLER` (1).
4746
4847
Using a function call is a good general-purpose technique for dealing with complex filter expressions. Two other C language features that are useful are:
4948
5049
- The conditional operator
5150
5251
- The comma operator
5352
54-
The conditional operator is frequently useful, because it can be used to check for a specific return code and then return one of two different values. For example, the filter in the following code recognizes the exception only if the exception is STATUS_INTEGER_OVERFLOW:
53+
The conditional operator is frequently useful here. It can be used to check for a specific return code and then return one of two different values. For example, the filter in the following code recognizes the exception only if the exception is `STATUS_INTEGER_OVERFLOW`:
5554
5655
```cpp
5756
__except( GetExceptionCode() == STATUS_INTEGER_OVERFLOW ? 1 : 0 ) {
@@ -63,9 +62,9 @@ The purpose of the conditional operator in this case is mainly to provide clarit
6362
__except( GetExceptionCode() == STATUS_INTEGER_OVERFLOW ) {
6463
```
6564
66-
The conditional operator is more useful in situations where you might want the filter to evaluate to -1, EXCEPTION_CONTINUE_EXECUTION.
65+
The conditional operator is more useful in situations where you might want the filter to evaluate to -1, `EXCEPTION_CONTINUE_EXECUTION`.
6766
68-
The comma operator enables you to perform multiple, independent operations inside a single expression. The effect is roughly that of executing multiple statements and then returning the value of the last expression. For example, the following code stores the exception code in a variable and then tests it:
67+
The comma operator lets you execute multiple expressions in sequence. It then returns the value of the last expression. For example, the following code stores the exception code in a variable and then tests it:
6968
7069
```cpp
7170
__except( nCode = GetExceptionCode(), nCode == STATUS_INTEGER_OVERFLOW )
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4027"
2+
description: "Learn more about compiler warning (level 1) C4027"
33
title: "Compiler Warning (level 1) C4027"
4-
ms.date: "11/04/2016"
4+
ms.date: 12/16/2020
55
f1_keywords: ["C4027"]
66
helpviewer_keywords: ["C4027"]
7-
ms.assetid: f30d57b9-20c4-4284-8686-566d9f0ca7fc
87
---
98
# Compiler Warning (level 1) C4027
109

11-
function declared without formal parameter list
10+
> function declared without formal parameter list
1211
13-
The function declaration no formal parameters, but there are formal parameters in the function definition or actual parameters in a call. Subsequent calls to this function assume that the function takes actual parameters of the types found in the function definition or call.
12+
The function declaration had no formal parameters, but there are formal parameters in the function definition or actual parameters in a call.
13+
14+
The compiler accepts, but warns, on an old C-style forward declaration of a function name without a parameter list. On later calls to this function, the compiler assumes that the function takes actual parameters of the types found in the function definition or call. We recommend you modify your function declaration
15+
to match the signature of the function definition.

docs/intrinsics/noop.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
---
2-
description: "Learn more about: __noop"
2+
description: "Learn more about Microsoft C/C++ intrinsic: __noop"
33
title: "__noop"
4-
ms.date: "09/02/2019"
4+
ms.date: 12/16/2020
55
f1_keywords: ["__noop_cpp", "__noop"]
66
helpviewer_keywords: ["__noop keyword [C++]"]
77
ms.assetid: 81ac6e97-7bf8-496b-b3c4-fd02837573e5
88
---
9-
# __noop
9+
# `__noop`
1010

11-
**Microsoft Specific**
12-
13-
The **`__noop`** intrinsic specifies that a function should be ignored. The argument list is parsed, but no code is generated for the arguments. It's intended for use in global debug functions that take a variable number of arguments.
11+
The **Microsoft-specific** **`__noop`** intrinsic specifies that a function should be ignored. The argument list is parsed, but no code is generated for the arguments. The compiler considers the arguments as referenced for the purposes of compiler warning C4100 and similar analysis. The `__noop` intrinsic is intended for use in global debug functions that take a variable number of arguments.
1412

1513
The compiler converts the **`__noop`** intrinsic to 0 at compile time.
1614

@@ -20,6 +18,7 @@ The following code shows how you could use **`__noop`**.
2018

2119
```cpp
2220
// compiler_intrinsics__noop.cpp
21+
// compile using: cl /EHsc /W4 compiler_intrinsics__noop.cpp
2322
// compile with or without /DDEBUG
2423
#include <stdio.h>
2524

@@ -29,13 +28,16 @@ The following code shows how you could use **`__noop`**.
2928
#define PRINT __noop
3029
#endif
3130

32-
int main() {
33-
PRINT("\nhello\n");
31+
#define IGNORE(x) { __noop(x); }
32+
33+
int main(int argv, char ** argc)
34+
{
35+
IGNORE(argv);
36+
IGNORE(argc);
37+
PRINT("\nDEBUG is defined\n");
3438
}
3539
```
3640
37-
**END Microsoft Specific**
38-
3941
## See also
4042
4143
[Compiler intrinsics](../intrinsics/compiler-intrinsics.md)\

docs/linux/connect-to-your-remote-linux-computer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ If ssh isn't already set up and running on your Linux system, follow these steps
118118

119119
## TCP Port Forwarding
120120

121-
Visual Studio's Linux support has a dependency on TCP port forwarding. **Rsync** and **gdbserver** are affected if TCP port forwarding is disabled on your remote system. If you're impacted by this dependency, you can upvote this [suggestion ticket](https://developercommunity.visualstudio.com/idea/840265/dont-rely-on-ssh-tcp-port-forwarding-for-c-remote.html) on Developer Community.
121+
Visual Studio's Linux support has a dependency on TCP port forwarding. **Rsync** and **gdbserver** are affected if TCP port forwarding is disabled on your remote system. If you're impacted by this dependency, you can upvote this [suggestion ticket](https://developercommunity2.visualstudio.com/t/shDonshshtsh-shrelysh-s/840265?space=62) on Developer Community.
122122

123123
rsync 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:
124124

0 commit comments

Comments
 (0)