You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build/working-with-project-properties.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ You can view and modify these properties by using *property pages*. To access th
15
15
16
16
When you create a project, the system assigns values for various properties. The defaults vary somewhat depending on the kind of project and what options you choose in the app wizard. For example, an Active Template Library (ATL) project has properties related to Microsoft Interface Definition Language (MIDL) files, but these properties are absent in a basic console application. The default properties are shown in the Advanced pane in the **Property Pages** window:
17
17
18
-
:::image type="content" source="media/visual-c---project-defaults.png" alt-text="Screenshot of the Visual Studio project properties dialog box with the Advanced pane selected." lightbox="media/visual-c---project-defaults.png":::
18
+
:::image type="content" source="media/visual-c---project-defaults.png" alt-text="Screenshot of the Visual Studio project properties dialog box with the Advanced pane selected. Properties such as Use of MFC, Character Set, and so on are highlighted." lightbox="media/visual-c---project-defaults.png":::
19
19
20
20
## Apply properties to build configurations and target platforms
@@ -11,10 +11,11 @@ This topic describes the basic application binary interface (ABI) for x64, the 6
11
11
## x64 calling conventions
12
12
13
13
Two important differences between x86 and x64 are:
14
+
14
15
- 64-bit addressing capability
15
16
- Sixteen 64-bit registers for general use.
16
17
17
-
Given the expanded register set, x64 uses the [__fastcall](../cpp/fastcall.md) calling convention and a RISC-based exception-handling model.
18
+
Given the expanded register set, x64 uses the [`__fastcall`](../cpp/fastcall.md) calling convention and a RISC-based exception-handling model.
18
19
19
20
The **`__fastcall`** convention uses registers for the first four arguments, and the stack frame to pass more arguments. For details on the x64 calling convention, including register usage, stack parameters, return values, and stack unwinding, see [x64 calling convention](x64-calling-convention.md).
20
21
@@ -116,7 +117,7 @@ _declspec(align(2)) struct {
116
117
}
117
118
```
118
119
119
-

120
+
:::image type="content" source="../build/media/vcamd_conv_ex_1_block.png" alt-text="Diagram showing the structure layout for example 1. The diagram shows 2 bytes of memory. Member a, a short, occupies bytes 0 through 1.":::
120
121
121
122
#### Example 2
122
123
@@ -130,7 +131,9 @@ _declspec(align(8)) struct {
130
131
}
131
132
```
132
133
133
-

134
+
:::image type="complex" source="../build/media/vcamd_conv_ex_2_block.png" alt-text="Diagram showing the structure layout for example 2.":::
135
+
The diagram shows 24 bytes of memory. Member a, an int, occupies bytes 0 through 3. The diagram shows padding for bytes 4 through 7. Member b, a double, occupies bytes 8 through 15. Member c, a short, occupies bytes 16 through 17. Bytes 18 through 23 are unused.
136
+
:::image-end:::
134
137
135
138
#### Example 3
136
139
@@ -145,7 +148,9 @@ _declspec(align(4)) struct {
145
148
}
146
149
```
147
150
148
-

151
+
:::image type="complex" source="../build/media/vcamd_conv_ex_3_block.png" alt-text="Diagram showing the structure layout for example 3.":::
152
+
The diagram shows 12 bytes of memory. Member a, a char, occupies byte 0. Byte 1 is padding. Member b, a short, occupies bytes 2 through 4. Member c, a char, occupies byte 4. Bytes 5 through 7 are padding. Member d, an int, occupies bytes 8 through 11.
153
+
:::image-end:::
149
154
150
155
#### Example 4
151
156
@@ -159,7 +164,9 @@ _declspec(align(8)) union {
159
164
}
160
165
```
161
166
162
-

167
+
:::image type="complex" source="../build/media/vcamd_conv_ex_4_block.png" alt-text="Diagram showing the union layout for example 4.":::
168
+
The diagram shows 8 bytes of memory. Member p, a char, occupies byte 0. Member s, a short, occupies bytes 0 through 1. Member l, a long, occupies bytes 0 through 3. Bytes 4 through 7 are padding.
169
+
:::image-end:::
163
170
164
171
### Bitfields
165
172
@@ -211,7 +218,7 @@ On function exit and on function entry to C Runtime Library calls and Windows sy
211
218
212
219
## Stack usage
213
220
214
-
For details on stack allocation, alignment, function types and stack frames on x64, see [x64 stack usage](stack-usage.md).
221
+
For details on stack allocation, alignment, function types, and stack frames on x64, see [x64 stack usage](stack-usage.md).
> Ill-defined for-loop: Loop body only executed once
10
+
> Ill-defined for-loop. Loop body only executed once.
12
11
13
12
## Remarks
14
13
15
-
This warning indicates that a for-loop might not function as intended. When the index is unsigned and a loop counts down from zero, its body is run only once.
14
+
This warning indicates that a for-loop might unintentionally execute only once. A loop with an unsigned index counting down from zero or a mistaken use of `==` might cause this warning.
16
15
17
16
Code analysis name: `LOOP_ONLY_EXECUTED_ONCE`
18
17
19
18
## Example
20
19
21
-
The following code generates this warning:
20
+
The following example generates C6296. Each for-loop shown executes exactly once.
Copy file name to clipboardExpand all lines: docs/code-quality/quick-start-code-analysis-for-c-cpp.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ You can improve the quality of your application by running code analysis regular
19
19
20
20
1. To run code analysis every time the project is built using the selected configuration, select the **Enable Code Analysis on Build** check box. You can also run code analysis manually by opening the **Analyze** menu and then choosing **Run Code Analysis on***ProjectName* or **Run Code Analysis on File**.
21
21
22
-
1. Choose the [rule set](using-rule-sets-to-specify-the-cpp-rules-to-run.md) that you want to use or create a [custom rule set](using-rule-sets-to-specify-the-cpp-rules-to-run.md#to-create-a-rule-set-in-a-text-editor). If using LLVM/clang-cl, see [Using Clang-Tidy in Visual Studio](../code-quality/clang-tidy.md) to configure Clang-Tidy analysis options.
22
+
1. Choose the [rule set](using-rule-sets-to-specify-the-cpp-rules-to-run.md) that you want to use or create a [custom rule set](using-rule-sets-to-specify-the-cpp-rules-to-run.md#to-create-a-rule-set-in-a-text-editor). If using LLVM/clang-cl, see [Using Clang-Tidy in Visual Studio](clang-tidy.md) to configure Clang-Tidy analysis options.
23
23
24
24
### Standard C/C++ rule sets
25
25
@@ -100,7 +100,7 @@ The Error List window lists the code analysis warnings found. The results are di
100
100
101
101
For detailed information about the warning, including possible solutions to the issue, choose the warning ID in the Code column to display its corresponding online help article.
102
102
103
-
Double-click a warning to move the cursor to the line of code that caused the warning in the Visual Studio code editor. Or, press Enter on the selected warning.
103
+
Double-click a warning to move the cursor to the line of code that caused the warning in the code editor. Or, press Enter on the selected warning.
104
104
105
105
After you understand the problem, you can resolve it in your code. Then, rerun code analysis to make sure that the warning no longer appears in the Error List.
106
106
@@ -128,4 +128,4 @@ You can search long lists of warning messages and you can filter warnings in mul
128
128
129
129
## See also
130
130
131
-
-[Code analysis for C/C++](../code-quality/code-analysis-for-c-cpp-overview.md)
131
+
-[Code analysis for C/C++](code-analysis-for-c-cpp-overview.md)
Copy file name to clipboardExpand all lines: docs/code-quality/understanding-sal.md
+20-21Lines changed: 20 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
1
---
2
-
description: "Learn more about: Understanding SAL"
3
2
title: Understanding SAL
3
+
description: "Learn more about: Understanding SAL"
4
4
ms.date: 11/04/2016
5
5
ms.topic: "conceptual"
6
-
ms.assetid: a94d6907-55f2-4874-9571-51d52d6edcfd
7
6
---
8
7
# Understanding SAL
9
8
@@ -94,9 +93,9 @@ These annotations help identify possible uninitialized values and invalid null p
94
93
95
94
This section shows code examples for the basic SAL annotations.
96
95
97
-
### Using the Visual Studio Code Analysis Tool to Find Defects
96
+
### Using the Visual Studio code analysis tool to find defects
98
97
99
-
In the examples, the Visual Studio Code Analysis tool is used together with SAL annotations to find code defects. Here's how to do that.
98
+
In the examples, the Visual Studio code analysis tool is used together with SAL annotations to find code defects. Here's how to do that.
100
99
101
100
#### To use Visual Studio code analysis tools and SAL
102
101
@@ -145,7 +144,7 @@ void BadInCaller()
145
144
}
146
145
```
147
146
148
-
If you use Visual Studio Code Analysis on this example, it validates that the callers pass a non-Null pointer to an initialized buffer for `pInt`. In this case, `pInt` pointer cannot be NULL.
147
+
If you use Visual Studio code analysis on this example, it validates that the callers pass a non-Null pointer to an initialized buffer for `pInt`. In this case, `pInt` pointer cannot be NULL.
149
148
150
149
### Example: The \_In\_opt\_ Annotation
151
150
@@ -172,7 +171,7 @@ void InOptCaller()
172
171
}
173
172
```
174
173
175
-
Visual Studio Code Analysis validates that the function checks for NULL before it accesses the buffer.
174
+
Visual Studio code analysis validates that the function checks for NULL before it accesses the buffer.
176
175
177
176
### Example: The \_Out\_ Annotation
178
177
@@ -198,7 +197,7 @@ void OutCaller()
198
197
}
199
198
```
200
199
201
-
Visual Studio Code Analysis Tool validates that the caller passes a non-NULL pointer to a buffer for `pInt` and that the buffer is initialized by the function before it returns.
200
+
Visual Studio code analysis validates that the caller passes a non-NULL pointer to a buffer for `pInt` and that the buffer is initialized by the function before it returns.
202
201
203
202
### Example: The \_Out\_opt\_ Annotation
204
203
@@ -225,7 +224,7 @@ void OutOptCaller()
225
224
}
226
225
```
227
226
228
-
Visual Studio Code Analysis validates that this function checks for NULL before `pInt` is dereferenced, and if `pInt` is not NULL, that the buffer is initialized by the function before it returns.
227
+
Visual Studio code analysis validates that this function checks for NULL before `pInt` is dereferenced, and if `pInt` is not NULL, that the buffer is initialized by the function before it returns.
229
228
230
229
### Example: The \_Inout\_ Annotation
231
230
@@ -256,7 +255,7 @@ void BadInOutCaller()
256
255
}
257
256
```
258
257
259
-
Visual Studio Code Analysis validates that callers pass a non-NULL pointer to an initialized buffer for `pInt`, and that, before return, `pInt` is still non-NULL and the buffer is initialized.
258
+
Visual Studio code analysis validates that callers pass a non-NULL pointer to an initialized buffer for `pInt`, and that, before return, `pInt` is still non-NULL and the buffer is initialized.
260
259
261
260
### Example: The \_Inout\_opt\_ Annotation
262
261
@@ -285,7 +284,7 @@ void InOutOptCaller()
285
284
}
286
285
```
287
286
288
-
Visual Studio Code Analysis validates that this function checks for NULL before it accesses the buffer, and if `pInt` is not NULL, that the buffer is initialized by the function before it returns.
287
+
Visual Studio code analysis validates that this function checks for NULL before it accesses the buffer, and if `pInt` is not NULL, that the buffer is initialized by the function before it returns.
289
288
290
289
### Example: The \_Outptr\_ Annotation
291
290
@@ -315,7 +314,7 @@ void OutPtrCaller()
315
314
}
316
315
```
317
316
318
-
Visual Studio Code Analysis validates that the caller passes a non-NULL pointer for `*pInt`, and that the buffer is initialized by the function before it returns.
317
+
Visual Studio code analysis validates that the caller passes a non-NULL pointer for `*pInt`, and that the buffer is initialized by the function before it returns.
319
318
320
319
### Example: The \_Outptr\_opt\_ Annotation
321
320
@@ -347,7 +346,7 @@ void OutPtrOptCaller()
347
346
}
348
347
```
349
348
350
-
Visual Studio Code Analysis validates that this function checks for NULL before `*pInt` is dereferenced, and that the buffer is initialized by the function before it returns.
349
+
Visual Studio code analysis validates that this function checks for NULL before `*pInt` is dereferenced, and that the buffer is initialized by the function before it returns.
351
350
352
351
### Example: The \_Success\_ Annotation in Combination with \_Out\_
353
352
@@ -366,7 +365,7 @@ bool GetValue(_Out_ int *pInt, bool flag)
366
365
}
367
366
```
368
367
369
-
The `_Out_` annotation causes Visual Studio Code Analysis to validate that the caller passes a non-NULL pointer to a buffer for `pInt`, and that the buffer is initialized by the function before it returns.
368
+
The `_Out_` annotation causes Visual Studio code analysis to validate that the caller passes a non-NULL pointer to a buffer for `pInt`, and that the buffer is initialized by the function before it returns.
370
369
371
370
## SAL Best Practice
372
371
@@ -384,18 +383,18 @@ Here are some guidelines:
384
383
385
384
- Annotate value-range annotations so that Code Analysis can ensure buffer and pointer safety.
386
385
387
-
- Annotate locking rules and locking side effects. For more information, see [Annotating Locking Behavior](../code-quality/annotating-locking-behavior.md).
386
+
- Annotate locking rules and locking side effects. For more information, see [Annotating Locking Behavior](annotating-locking-behavior.md).
388
387
389
388
- Annotate driver properties and other domain-specific properties.
390
389
391
390
Or you can annotate all parameters to make your intent clear throughout and to make it easy to check that annotations have been done.
392
391
393
392
## See also
394
393
395
-
-[Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md)
396
-
-[Annotating Function Parameters and Return Values](../code-quality/annotating-function-parameters-and-return-values.md)
397
-
-[Annotating Function Behavior](../code-quality/annotating-function-behavior.md)
398
-
-[Annotating Structs and Classes](../code-quality/annotating-structs-and-classes.md)
Copy file name to clipboardExpand all lines: docs/code-quality/using-the-cpp-core-guidelines-checkers.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -317,11 +317,11 @@ Because of the way the code analysis rules get loaded within Visual Studio 2015,
317
317
318
318
1. In the **NuGet Package Manager** window, search for Microsoft.CppCoreCheck.
319
319
320
-

320
+

321
321
322
322
1. Select the Microsoft.CppCoreCheck package and then choose the **Install** button to add the rules to your project.
323
323
324
-
The NuGet package adds an MSBuild *`.targets`* file to your project that is invoked when you enable code analysis on your project. The *`.targets`* file adds the C++ Core Check rules as another extension to the Visual Studio Code analysis tool. When the package is installed, you can use the Property Pages dialog to enable or disable the released and experimental rules.
324
+
The NuGet package adds an MSBuild *`.targets`* file to your project that is invoked when you enable code analysis on your project. The *`.targets`* file adds the C++ Core Check rules as another extension to the Visual Studio code analysis tool. When the package is installed, you can use the Property Pages dialog to enable or disable the released and experimental rules.
Copy file name to clipboardExpand all lines: docs/dotnet/how-to-declare-override-specifiers-in-native-compilations-cpp-cli.md
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,15 @@
1
1
---
2
-
description: "Learn more about: How to: Declare Override Specifiers in Native Compilations (C++/CLI)"
3
2
title: "How to: Declare Override Specifiers (C++/CLI)"
3
+
description: "Learn more about: How to: Declare Override Specifiers in Native Compilations (C++/CLI)"
4
4
ms.date: "11/04/2016"
5
5
helpviewer_keywords: ["override specifiers in native compilation, overriding"]
6
-
ms.assetid: d0551836-9ac7-41eb-a6e9-a4b3ef60767d
7
6
---
8
7
# How to: Declare Override Specifiers in Native Compilations (C++/CLI)
9
8
10
-
[sealed](../extensions/sealed-cpp-component-extensions.md), [abstract](../extensions/abstract-cpp-component-extensions.md), and [override](../extensions/override-cpp-component-extensions.md) are available in compilations that do not use **/ZW** or [/clr](../build/reference/clr-common-language-runtime-compilation.md).
9
+
[`sealed`](../extensions/sealed-cpp-component-extensions.md), [`abstract`](../extensions/abstract-cpp-component-extensions.md), and [`override`](../extensions/override-cpp-component-extensions.md) are available in compilations that do not use **/ZW** or [`/clr`](../build/reference/clr-common-language-runtime-compilation.md).
11
10
12
11
> [!NOTE]
13
-
> The ISO C++11 Standard language has the [override](../cpp/override-specifier.md)identifier and the [final](../cpp/final-specifier.md)identifier, and both are supported in Visual Studio Use `final` instead of **`sealed`** in code that is meant to be compiled as native-only.
12
+
> The ISO C++11 Standard language [`override`](../cpp/override-specifier.md) and [`final`](../cpp/final-specifier.md)specifiers are supported in Visual Studio. Use `final` instead of **`sealed`** in code that is meant to be compiled as native-only.
14
13
15
14
## Example: sealed is valid
16
15
@@ -67,7 +66,7 @@ public:
67
66
68
67
### Description
69
68
70
-
This example shows that **`abstract`** is valid in native compilations.
69
+
This example shows that `abstract` is valid in native compilations.
description: "Learn more about: Compiler Error C2162"
3
2
title: "Compiler Error C2162"
4
-
ms.date: "11/04/2016"
3
+
description: "Learn more about: Compiler Error C2162"
4
+
ms.date: "03/30/2025"
5
5
f1_keywords: ["C2162"]
6
6
helpviewer_keywords: ["C2162"]
7
-
ms.assetid: 34923628-d35e-48ab-9072-b95e3b5f6b45
8
7
---
9
8
# Compiler Error C2162
10
9
11
-
expected macro formal parameter
10
+
> expected macro formal parameter
12
11
13
-
The token following a stringizing operator (#)is not a formal parameter name.
12
+
The token following a [stringizing operator (#)](../../preprocessor/stringizing-operator-hash.md) or a [charizing operator (#@)](../../preprocessor/charizing-operator-hash-at.md)is not a formal parameter.
0 commit comments