Skip to content

Commit 3f5996c

Browse files
author
Colin Robertson
authored
Merge pull request #3962 from MicrosoftDocs/main637901341545055499
Repo sync for protected CLA branch
2 parents 849f7af + 88e9bc2 commit 3f5996c

19 files changed

+102
-105
lines changed
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
---
22
description: "Learn more about: Data Directives and Operators in Inline Assembly"
33
title: "Data Directives and Operators in Inline Assembly"
4-
ms.date: "08/30/2018"
4+
ms.date: 06/03/2022
55
helpviewer_keywords: ["data directives [C++]", "__asm keyword [C++], referencing limitations", "MASM (Microsoft Macro Assembler), directives", "directives [C++], MASM", "MASM (Microsoft Macro Assembler), structures", "operators [MASM]", "inline assembly, operators", "inline assembly, data directives", "MASM (Microsoft Macro Assembler), operators", "structures [C++], MASM"]
66
ms.assetid: fb7410c7-156a-4131-bcfc-211aa70533e3
77
---
8-
# Data Directives and Operators in Inline Assembly
8+
# Data directives and operators in inline assembly
99

1010
**Microsoft Specific**
1111

12-
Although an **`__asm`** block can reference C or C++ data types and objects, it cannot define data objects with MASM directives or operators. Specifically, you cannot use the definition directives **DB**, `DW`, **DD**, `DQ`, `DT`, and `DF`, or the operators `DUP` or **THIS**. MASM structures and records are also unavailable. The inline assembler doesn't accept the directives `STRUC`, `RECORD`, **WIDTH**, or **MASK**.
12+
The inline assembler doesn't support all the data directives and operators available in MASM.
13+
14+
## Remarks
15+
16+
Although an **`__asm`** block can reference C or C++ data types and objects, it can't define data objects with MASM directives or operators. Specifically, you can't use the definition directives **`DB`**, **`DW`**, **`DD`**, **`DQ`**, **`DT`**, and **`DF`**, or the operators **`DUP`** or **`THIS`**. MASM structures and records are also unavailable. The inline assembler doesn't accept the directives **`STRUC`**, **`RECORD`**, **`WIDTH`**, or **`MASK`**.
1317

1418
**END Microsoft Specific**
1519

1620
## See also
1721

18-
[Using Assembly Language in __asm Blocks](../../assembler/inline/using-assembly-language-in-asm-blocks.md)<br/>
22+
[Using Assembly Language in `__asm` blocks](../../assembler/inline/using-assembly-language-in-asm-blocks.md)

docs/assembler/masm/ml-nonfatal-error-a2010.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ ms.assetid: 8bcd57f4-1e3f-421f-9ef8-e702daf57fcb
99
---
1010
# ML Nonfatal Error A2010
1111

12-
**invalid type expression**
12+
> **invalid type expression**
1313
14-
The operand to [THIS](operator-this.md) or [PTR](operator-ptr.md) was not a valid type expression.
14+
## Remarks
15+
16+
The operand to [`THIS`](operator-this.md) or [`PTR`](operator-ptr.md) wasn't a valid type expression.
1517

1618
## See also
1719

docs/assembler/masm/ml-nonfatal-error-a2034.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@ ms.assetid: 6438970c-0aee-4f14-a058-5fe47d0ee216
99
---
1010
# ML Nonfatal Error A2034
1111

12-
**must be in segment block**
12+
> **must be in segment block**
1313
14-
One of the following was found outside of a segment block:
14+
## Remarks
15+
16+
The assembler found one of the following items outside of a segment block:
1517

1618
- An instruction
1719

1820
- A label definition
1921

20-
- A [THIS](operator-this.md) operator
22+
- A [`THIS`](operator-this.md) operator
2123

22-
- A [$](dollar.md) operator
24+
- A [`$`](dollar.md) operator
2325

2426
- A procedure definition
2527

26-
- An [ALIGN](align-masm.md) directive
28+
- An [`ALIGN`](align-masm.md) directive
2729

28-
- An [ORG](org.md) directive
30+
- An [`ORG`](org.md) directive
2931

3032
## See also
3133

docs/assembler/masm/operator-this.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ f1_keywords: ["this", "operator THIS"]
66
helpviewer_keywords: ["operator THIS", "THIS operator"]
77
ms.assetid: d795aa0e-6c01-49b7-8c64-8ab111fd82d3
88
---
9-
# operator THIS
9+
# operator `THIS`
1010

1111
Returns an operand of specified *type* whose offset and segment values are equal to the current location counter value.
1212

1313
## Syntax
1414

15-
> **THIS** *type*
15+
> **`THIS`** *type*
1616
1717
## See also
1818

docs/build/cmake-presets-vs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ Instead, set the path to `vcpkg.cmake` by using the `VCPKG_ROOT` environment var
378378

379379
`VCPKG_ROOT` should be set to the root of your vcpkg installation. For more information, see [vcpkg environment variables](https://github.com/microsoft/vcpkg/blob/master/docs/users/config-environment.md).
380380

381-
If you're already using a CMake toolchain file and want to enable vcpkg integration, see [Using multiple toolchain files](https://github.com/microsoft/vcpkg/blob/master/docs/users/integration.md#using-multiple-toolchain-files). Follow those instructions to use an external toolchain file with a project by using vcpkg.
381+
If you're already using a CMake toolchain file and want to enable vcpkg integration, see [Using multiple toolchain files](https://github.com/microsoft/vcpkg/blob/master/docs/users/buildsystems/integration.md#using-multiple-toolchain-files). Follow those instructions to use an external toolchain file with a project by using vcpkg.
382382

383383
## Variable substitution in *`launch.vs.json`* and *`tasks.vs.json`*
384384

docs/error-messages/compiler-errors-1/compiler-error-c2108.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
---
22
description: "Learn more about: Compiler Error C2108"
33
title: "Compiler Error C2108"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/03/2022
55
f1_keywords: ["C2108"]
66
helpviewer_keywords: ["C2108"]
77
ms.assetid: c84f0b47-5e2c-47d2-8edb-427a40e17c36
88
---
99
# Compiler Error C2108
1010

11-
subscript is not of integral type
11+
> subscript is not of integral type
1212
13-
The array subscript is a noninteger expression.
13+
## Remarks
14+
15+
The array subscript is a non-integer expression.
1416

1517
## Example
1618

17-
C2108 can occur if you incorrectly use the **`this`** pointer of a value type to access the type's default indexer. For more information, see [Semantics of the this pointer](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Semantics_of_the_this_pointer).
19+
C2108 can occur if you incorrectly use the **`this`** pointer of a value type to access the type's default indexer. For more information, see [Semantics of the `this` pointer](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Semantics_of_the_this_pointer).
1820

1921
The following sample generates C2108.
2022

docs/error-messages/compiler-errors-2/compiler-error-c2676.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
---
22
description: "Learn more about: Compiler Error C2676"
33
title: "Compiler Error C2676"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/03/2022
55
f1_keywords: ["C2676"]
66
helpviewer_keywords: ["C2676"]
77
ms.assetid: 838a5e34-c92f-4f65-a597-e150bf8cf737
88
---
99
# Compiler Error C2676
1010

11-
binary 'operator' : 'type' does not define this operator or a conversion to a type acceptable to the predefined operator
11+
> binary '*operator*' : 'type*' does not define this operator or a conversion to a type acceptable to the predefined operator
12+
13+
## Remarks
1214

1315
To use the operator, you must overload it for the specified type or define a conversion to a type for which the operator is defined.
1416

@@ -46,7 +48,7 @@ int main() {
4648
4749
C2676 can also occur if you attempt to do pointer arithmetic on the **`this`** pointer of a reference type.
4850
49-
The **`this`** pointer is of type handle in a reference type. For more information, see [Semantics of the this pointer](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Semantics_of_the_this_pointer).
51+
The **`this`** pointer is of type handle in a reference type. For more information, see [Semantics of the `this` pointer](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Semantics_of_the_this_pointer).
5052
5153
The following sample generates C2676.
5254

docs/error-messages/tool-errors/linker-tools-error-lnk1104.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ If the *filename* is named LNK*nnn*, it's a filename generated by the linker for
126126

127127
When none of the issues listed here apply, you can use the feedback tools in Visual Studio for help. In the IDE, go to the menu bar and choose **Help > Send Feedback > Report a Problem**. Or, submit a suggestion by using **Help > Send Feedback > Send a Suggestion**. You can also use the [Microsoft Docs Q&A](/answers/topics/c%2B%2B.html) site for questions, and the Visual Studio C++ [Developer Community](https://aka.ms/vsfeedback/browsecpp) website. Use these sites to search for answers to questions and ask for help. For more information, see [How to report a problem with the Visual C++ toolset or documentation](../../overview/how-to-report-a-problem-with-the-visual-cpp-toolset.md).
128128

129-
If you've discovered a new way to fix this issue that we should add to this article, let us know. You can send us feedback by using the button below for **this page**. Use it to create a new issue in our [C++ documentation GitHub repo](https://github.com/MicrosoftDocs/cpp-docs/issues). Thanks!
129+
If you've discovered a new way to fix this issue that we should add to this article, let us know. You can send us feedback by using the button below for **This page**. Use it to create a new issue in our [C++ documentation GitHub repo](https://github.com/MicrosoftDocs/cpp-docs/issues). Thanks!
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
---
2-
description: "Learn more about: TN017: Destroying Window Objects"
3-
title: "TN017: Destroying Window Objects"
4-
ms.date: "11/04/2016"
2+
description: "Learn more about: TN017: Destroying window objects"
3+
title: "TN017: Destroying window objects"
4+
ms.date: 06/03/2022
55
f1_keywords: ["vc.objects"]
66
helpviewer_keywords: ["destroying windows", "TN017", "PostNcDestroy method [MFC]"]
77
ms.assetid: 5bf208a5-5683-439b-92a1-547c5ded26cd
88
---
9-
# TN017: Destroying Window Objects
9+
# TN017: Destroying window objects
1010

11-
This note describes the use of the [CWnd::PostNcDestroy](../mfc/reference/cwnd-class.md#postncdestroy) method. Use this method if you want to do customized allocation of `CWnd`-derived objects. This note also explains why you should use [CWnd::DestroyWindow](../mfc/reference/cwnd-class.md#destroywindow) to destroy a C++ Windows object instead of the **`delete`** operator.
11+
This note describes the use of the [`CWnd::PostNcDestroy`](../mfc/reference/cwnd-class.md#postncdestroy) method. Use this method if you want to do customized allocation of `CWnd`-derived objects. This note also explains why you should use [`CWnd::DestroyWindow`](../mfc/reference/cwnd-class.md#destroywindow) to destroy a C++ Windows object instead of the **`delete`** operator.
1212

13-
If you follow the guidelines in this topic, you will have few cleanup problems. These problems can result from issues such as forgetting to delete/free C++ memory, forgetting to free system resources like `HWND`s, or freeing objects too many times.
13+
If you follow the guidelines in this article, you'll have few cleanup problems. These problems can result from issues such as forgetting to delete/free C++ memory, forgetting to free system resources like `HWND`s, or freeing objects too many times.
1414

15-
## The Problem
15+
## The problem
1616

1717
Each windows object (object of a class derived from `CWnd`) represents both a C++ object and an `HWND`. C++ objects are allocated in the application's heap and `HWND`s are allocated in system resources by the window manager. Because there are several ways to destroy a window object, we must provide a set of rules that prevent system resource or memory leaks. These rules must also prevent objects and Windows handles from being destroyed more than one time.
1818

19-
## Destroying Windows
19+
## Destroying windows
2020

2121
The following are the two permitted ways to destroy a Windows object:
2222

2323
- Calling `CWnd::DestroyWindow` or the Windows API `DestroyWindow`.
2424

2525
- Explicitly deleting with the **`delete`** operator.
2626

27-
The first case is by far the most common. This case applies even if your code does not call `DestroyWindow` directly. When the user directly closes a frame window, this action generates the WM_CLOSE message, and the default response to this message is to call `DestroyWindow`. When a parent window is destroyed, Windows calls `DestroyWindow` for all its children.
27+
The first case is by far the most common. This case applies even if your code doesn't call `DestroyWindow` directly. When the user directly closes a frame window, this action generates the WM_CLOSE message, and the default response to this message is to call `DestroyWindow`. When a parent window is destroyed, Windows calls `DestroyWindow` for all its children.
2828

2929
The second case, the use of the **`delete`** operator on Windows objects, should be rare. The following are some cases where using **`delete`** is the correct choice.
3030

31-
## Auto Cleanup with CWnd::PostNcDestroy
31+
## Auto cleanup with `CWnd::PostNcDestroy`
3232

33-
When the system destroys a Windows window, the last Windows message sent to the window is WM_NCDESTROY. The default `CWnd` handler for that message is [CWnd::OnNcDestroy](../mfc/reference/cwnd-class.md#onncdestroy). `OnNcDestroy` will detach the `HWND` from the C++ object and call the virtual function `PostNcDestroy`. Some classes override this function to delete the C++ object.
33+
When the system destroys a Windows window, the last Windows message sent to the window is `WM_NCDESTROY`. The default `CWnd` handler for that message is [`CWnd::OnNcDestroy`](../mfc/reference/cwnd-class.md#onncdestroy). `OnNcDestroy` will detach the `HWND` from the C++ object and call the virtual function `PostNcDestroy`. Some classes override this function to delete the C++ object.
3434

35-
The default implementation of `CWnd::PostNcDestroy` does nothing, which is appropriate for window objects that are allocated on the stack frame or embedded in other objects. This is not appropriate for window objects that are designed to be allocated on the heap without any other objects. In other words, it is not appropriate for window objects that are not embedded in other C++ objects.
35+
The default implementation of `CWnd::PostNcDestroy` does nothing, which is appropriate for window objects that are allocated on the stack frame or embedded in other objects. This behavior isn't appropriate for window objects designed for allocation on the heap without any other objects. In other words, it isn't appropriate for window objects that aren't embedded in other C++ objects.
3636

37-
Those classes that are designed to be allocated alone on the heap override the `PostNcDestroy` method to perform a `delete this;`. This statement will free any memory associated with the C++ object. Even though the default `CWnd` destructor calls `DestroyWindow` if *m_hWnd* is non-NULL, this does not lead to infinite recursion because the handle will be detached and NULL during the cleanup phase.
37+
Classes designed for allocation alone on the heap override the `PostNcDestroy` method to perform a `delete this;`. This statement will free any memory associated with the C++ object. Even though the default `CWnd` destructor calls `DestroyWindow` if *`m_hWnd`* isn't `NULL`, this call doesn't lead to infinite recursion because the handle will be detached and `NULL` during the cleanup phase.
3838

3939
> [!NOTE]
40-
> The system usually calls `CWnd::PostNcDestroy` after it processes the Windows WM_NCDESTROY message and the `HWND` and the C++ window object are no longer connected. The system will also call `CWnd::PostNcDestroy` in the implementation of most [CWnd::Create](../mfc/reference/cwnd-class.md#create) calls if failure occurs. The auto cleanup rules are described later in this topic.
40+
> The system usually calls `CWnd::PostNcDestroy` after it processes the Windows `WM_NCDESTROY` message and the `HWND` and the C++ window object are no longer connected. The system will also call `CWnd::PostNcDestroy` in the implementation of most [`CWnd::Create`](../mfc/reference/cwnd-class.md#create) calls if failure occurs. The auto cleanup rules are described later in this article.
4141
42-
## Auto Cleanup Classes
42+
## Auto cleanup classes
4343

44-
The following classes are not designed for auto-cleanup. They are typically embedded in other C++ objects or on the stack:
44+
The following classes aren't designed for auto-cleanup. They're typically embedded in other C++ objects or on the stack:
4545

4646
- All standard Windows controls (`CStatic`, `CEdit`, `CListBox`, and so on).
4747

@@ -57,7 +57,7 @@ The following classes are not designed for auto-cleanup. They are typically embe
5757

5858
- The default dialogs created by ClassWizard.
5959

60-
The following classes are designed for auto-cleanup. They are typically allocated by themselves on the heap:
60+
The following classes are designed for auto-cleanup. They're typically allocated by themselves on the heap:
6161

6262
- Main frame windows (derived directly or indirectly from `CFrameWnd`).
6363

@@ -67,24 +67,24 @@ If you want to break these rules, you must override the `PostNcDestroy` method i
6767

6868
The most common use of changing auto cleanup behavior is to create a modeless dialog that can be allocated on the heap.
6969

70-
## When to Call delete
70+
## When to call `delete`
7171

7272
We recommend that you call `DestroyWindow` to destroy a Windows object, either the C++ method or the global `DestroyWindow` API.
7373

74-
Do not call the global `DestroyWindow` API to destroy a MDI Child window. You should use the virtual method `CWnd::DestroyWindow` instead.
74+
Don't call the global `DestroyWindow` API to destroy an MDI Child window. You should use the virtual method `CWnd::DestroyWindow` instead.
7575

76-
For C++ Window objects that do not perform auto-cleanup, using the **`delete`** operator can cause a memory leak when you try to call `DestroyWindow` in the `CWnd::~CWnd` destructor if the VTBL does not point to the correctly derived class. This occurs because the system cannot find the appropriate destroy method to call. Using `DestroyWindow` instead of **`delete`** avoids these problems. Because this can be a subtle error, compiling in debug mode will generate the following warning if you are at risk.
76+
For C++ Window objects that don't perform auto-cleanup, using the **`delete`** operator can cause a memory leak when you try to call `DestroyWindow` in the `CWnd::~CWnd` destructor if the `VTBL` doesn't point to the correctly derived class. The leak occurs because the system can't find the appropriate destroy method to call. Using `DestroyWindow` instead of **`delete`** avoids these problems. Because this error can be subtle, compiling in debug mode will generate the following warning if you are at risk.
7777

78-
```
78+
```Output
7979
Warning: calling DestroyWindow in CWnd::~CWnd
8080
OnDestroy or PostNcDestroy in derived class will not be called
8181
```
8282

83-
In the case of C++ Windows objects that do perform auto-cleanup, you must call `DestroyWindow`. If you use the **`delete`** operator directly, the MFC diagnostic memory allocator will notify you that you are freeing memory two times. The two occurrences are your first explicit call and the indirect call to `delete this;` in the auto-cleanup implementation of `PostNcDestroy`.
83+
For C++ Windows objects that do perform auto-cleanup, you must call `DestroyWindow`. If you use the **`delete`** operator directly, the MFC diagnostic memory allocator will notify you that you're freeing memory two times. The two occurrences are your first explicit call and the indirect call to `delete this;` in the auto-cleanup implementation of `PostNcDestroy`.
8484

85-
After you call `DestroyWindow` on a non-auto-cleanup object, the C++ object will still be around, but *m_hWnd* will be NULL. After you call `DestroyWindow` on an auto-cleanup object, the C++ object will be gone, freed by the C++ delete operator in the auto-cleanup implementation of `PostNcDestroy`.
85+
After you call `DestroyWindow` on a non-auto-cleanup object, the C++ object will still be around, but *`m_hWnd`* will be `NULL`. After you call `DestroyWindow` on an auto-cleanup object, the C++ object will be gone, freed by the C++ delete operator in the auto-cleanup implementation of `PostNcDestroy`.
8686

8787
## See also
8888

89-
[Technical Notes by Number](../mfc/technical-notes-by-number.md)<br/>
90-
[Technical Notes by Category](../mfc/technical-notes-by-category.md)
89+
[Technical notes by number](../mfc/technical-notes-by-number.md)\
90+
[Technical notes by category](../mfc/technical-notes-by-category.md)

0 commit comments

Comments
 (0)