Skip to content

Commit 222b9cd

Browse files
authored
Merge pull request #4862 from MicrosoftDocs/main
4/04 AM Publish
2 parents e0473fe + 0882822 commit 222b9cd

File tree

9 files changed

+763
-754
lines changed

9 files changed

+763
-754
lines changed

docs/atl/reference/compiler-options-macros.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.date: 02/01/2023
55
f1_keywords: ["_ATL_ALL_WARNINGS", "_ATL_APARTMENT_THREADED", "_ATL_CSTRING_EXPLICIT_CONSTRUCTORS ", "_ATL_ENABLE_PTM_WARNING", "_ATL_FREE_THREADED", "_ATL_MODULES", "_ATL_MULTI_THREADED", "_ATL_NO_AUTOMATIC_NAMESPACE", "_ATL_NO_COM_SUPPORT", "ATL_NO_VTABLE", "ATL_NOINLINE", "_ATL_SINGLE_THREADED"]
66
helpviewer_keywords: ["compiler options, macros"]
77
---
8-
# Compiler Options Macros
8+
# Compiler Options Macros acrolinx
99

1010
These macros control specific compiler features.
1111

@@ -14,7 +14,7 @@ These macros control specific compiler features.
1414
|[`_ATL_ALL_WARNINGS`](#_atl_all_warnings)|A symbol that enables errors in projects converted from previous versions of ATL.|
1515
|[`_ATL_APARTMENT_THREADED`](#_atl_apartment_threaded)|Define if one or more of your objects use apartment threading.|
1616
|[`_ATL_CSTRING_EXPLICIT_CONSTRUCTORS`](#_atl_cstring_explicit_constructors)|Makes certain `CString` constructors explicit, preventing any unintentional conversions.|
17-
|[`_ATL_ENABLE_PTM_WARNING`](#_atl_enable_ptm_warning)|Define this macro to require C++ standard syntax. It generates the C4867 compiler error when non-standard syntax is used to initialize a pointer to a member function.|
17+
|[`_ATL_ENABLE_PTM_WARNING`](#_atl_enable_ptm_warning)|Define this macro to require C++ standard syntax. It generates the C4867 compiler error when nonstandard syntax is used to initialize a pointer to a member function.|
1818
|[`_ATL_FREE_THREADED`](#_atl_free_threaded)|Define if one or more of your objects use free or neutral threading.|
1919
|[`_ATL_MODULES`](#_ATL_MODULES)|Allows you to compile ATL projects with [permissive-](../../build/reference/permissive-standards-conformance.md) and use ATL with [C++ modules](../../cpp/modules-cpp.md).|
2020
|[`_ATL_MULTI_THREADED`](#_atl_multi_threaded)|A symbol that indicates the project has objects marked as Both, Free or Neutral. The macro [`_ATL_FREE_THREADED`](#_atl_free_threaded) should be used instead.|
@@ -64,7 +64,7 @@ New projects have this `#define` set in *pch.h* (*stdafx.h* in Visual Studio 201
6464

6565
Define if one or more of your objects use apartment threading.
6666

67-
```
67+
```cpp
6868
_ATL_APARTMENT_THREADED
6969
```
7070

@@ -88,7 +88,7 @@ By using the `_T` macro on all constructor string arguments, you can define `_AT
8888

8989
## <a name="_atl_enable_ptm_warning"></a> `_ATL_ENABLE_PTM_WARNING`
9090

91-
Define this macro in order to force the use of ANSI C++ standard-conforming syntax for pointer to member functions. Using this macro causes the C4867 compiler error to be generated when non-standard syntax is used to initialize a pointer to a member function.
91+
Define this macro in order to force the use of ANSI C++ standard-conforming syntax for pointer to member functions. Using this macro causes the C4867 compiler error to be generated when nonstandard syntax is used to initialize a pointer to a member function.
9292

9393
```cpp
9494
#define _ATL_ENABLE_PTM_WARNING
@@ -100,7 +100,7 @@ The ATL and MFC libraries have been changed to match the Microsoft C++ compiler'
100100

101101
When [`_ATL_ENABLE_PTM_WARNING`](#_atl_enable_ptm_warning) isn't defined (the default case), ATL/MFC disables the C4867 error in macro maps (notably message maps) so that code that was created in earlier versions can continue to build as before. If you define `_ATL_ENABLE_PTM_WARNING`, your code should conform to the C++ standard.
102102

103-
However, the non-standard form has been deprecated. You need to move existing code to C++ standard syntax. For example, the following code:
103+
However, the nonstandard form has been deprecated. You need to move existing code to C++ standard syntax. For example, the following code:
104104

105105
[!code-cpp[NVC_MFCListView#14](../../atl/reference/codesnippet/cpp/compiler-options-macros_2.cpp)]
106106

@@ -132,7 +132,7 @@ _ATL_MODULES
132132

133133
## <a name="_atl_multi_threaded"></a> `_ATL_MULTI_THREADED`
134134

135-
A symbol that indicates the project will have objects that are marked as Both, Free or Neutral.
135+
A symbol that indicates the project has objects that are marked as Both, Free or Neutral.
136136

137137
```
138138
_ATL_MULTI_THREADED
@@ -193,11 +193,11 @@ A symbol that indicates a function shouldn't be inlined.
193193
### Parameters
194194

195195
*`myfunction`*\
196-
The function that should not be inlined.
196+
The function that shouldn't be inlined.
197197

198198
### Remarks
199199

200-
Use this symbol if you want to ensure a function does not get inlined by the compiler, even though it must be declared as inline so that it can be placed in a header file. Expands to `__declspec(noinline)`.
200+
Use this symbol if you want to ensure a function doesn't get inlined by the compiler, even though it must be declared as inline so that it can be placed in a header file. Expands to `__declspec(noinline)`.
201201

202202
## <a name="_atl_single_threaded"></a> `_ATL_SINGLE_THREADED`
203203

docs/cpp/cpp-bit-fields.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ description: "Learn more about: C++ Bit Fields"
33
title: "C++ Bit Fields"
44
ms.date: "11/19/2018"
55
helpviewer_keywords: ["bitfields [C++]", "fields [C++], bit", "bit fields"]
6-
ms.assetid: 6f4b62e3-cc1d-4e5d-bf34-05904104f71a
76
---
87
# C++ Bit Fields
98

@@ -15,7 +14,7 @@ Classes and structures can contain members that occupy less storage than an inte
1514

1615
## Remarks
1716

18-
The (optional) *declarator* is the name by which the member is accessed in the program. It must be an integral type (including enumerated types). The *constant-expression* specifies the number of bits the member occupies in the structure. Anonymous bit fieldsthat is, bit-field members with no identifiercan be used for padding.
17+
The (optional) *declarator* is the name by which the member is accessed in the program. It must be an integral type (including enumerated types). The *constant-expression* specifies the number of bits the member occupies in the structure. Anonymous bit fieldsthat is, bit-field members with no identifiercan be used for padding.
1918

2019
> [!NOTE]
2120
> An unnamed bit field of width 0 forces alignment of the next bit field to the next **type** boundary, where **type** is the type of the member.
@@ -33,20 +32,21 @@ struct Date {
3332
};
3433
```
3534
36-
The conceptual memory layout of an object of type `Date` is shown in the following figure.
35+
The conceptual memory layout of an object of type `Date` is shown in the following figure:
3736
38-
![Memory layout of a date object, showing the nWeekDay, nMonthDay, nMonth, and nYear bit fields.](../cpp/media/vc38uq1.png "Memory layout of a date object") <br/>
39-
Memory Layout of Date Object
37+
:::image type="complex" source="../cpp/media/vc38uq1.png" alt-text="Diagram of the memory layout of a date object, showing where the n WeekDay, n MonthDay, n Month, and n Year bit fields are located.":::
38+
32 bits of memory are displayed in a row. Starting with the least significant bit, 3 bits are for nWeekDay. The next 6 bits are for nMonthDay. The next 5 bits are for nMonth. The next 2 bits are unused. The next 8 bits are for nYear. The remaining 8 bits are unused.
39+
:::image-end:::
4040
41-
Note that `nYear` is 8 bits long and would overflow the word boundary of the declared type, **`unsigned short`**. Therefore, it is begun at the beginning of a new **`unsigned short`**. It is not necessary that all bit fields fit in one object of the underlying type; new units of storage are allocated, according to the number of bits requested in the declaration.
41+
`nYear` is 8 bits long, which would overflow the word boundary of the declared type, **`unsigned short`**. Therefore, it starts at the beginning of a new **`unsigned short`**. It isn't necessary that all bit fields fit in one object of the underlying type; new units of storage are allocated, according to the number of bits requested in the declaration.
4242
4343
**Microsoft Specific**
4444
45-
The ordering of data declared as bit fields is from low to high bit, as shown in the figure above.
45+
The ordering of data declared as bit fields is from low to high bit, as shown in the previous figure.
4646
4747
**END Microsoft Specific**
4848
49-
If the declaration of a structure includes an unnamed field of length 0, as shown in the following example,
49+
If the declaration of a structure includes an unnamed field of length 0, as shown in the following example:
5050
5151
```cpp
5252
// bit_fields2.cpp
@@ -60,14 +60,15 @@ struct Date {
6060
};
6161
```
6262

63-
then the memory layout is as shown in the following figure:
63+
Then the memory layout is as shown in the following figure:
6464

65-
![Layout of a Date object with a zero length bit field, which forces alignment padding.](../cpp/media/vc38uq2.png) <br/>
66-
Layout of Date Object with Zero-Length Bit Field
65+
:::image type="complex" source="../cpp/media/vc38uq2.png" alt-text="Diagram of the layout of a Date object, with a zero length bit field, which forces alignment padding.":::
66+
64 bits of memory are displayed in a row. Starting with the least significant bit, 5 bits are for n Month. The next 8 bits are for n Year. The next 19 bits are unused. The next 3 bits are for n WeekDay. The next 6 bits are for n MonthDay. The remaining bits are unused.
67+
:::image-end:::
6768

6869
The underlying type of a bit field must be an integral type, as described in [Built-in types](../cpp/fundamental-types-cpp.md).
6970

70-
If the initializer for a reference of type `const T&` is an lvalue that refers to a bit field of type `T`, the reference is not bound to the bit field directly. Instead, the reference is bound to a temporary initialized to hold the value of the bit field.
71+
If the initializer for a reference of type `const T&` is an lvalue that refers to a bit field of type `T`, the reference isn't bound to the bit field directly. Instead, the reference is bound to a temporary initialized to hold the value of the bit field.
7172

7273
## Restrictions on bit fields
7374

docs/cpp/dynamic-cast-operator.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ description: "Overview of the C++ language dynamic_cast operator."
44
ms.date: "02/03/2020"
55
f1_keywords: ["dynamic_cast_cpp"]
66
helpviewer_keywords: ["dynamic_cast keyword [C++]"]
7-
ms.assetid: f380ada8-6a18-4547-93c9-63407f19856b
87
---
98
# dynamic_cast Operator
109

@@ -20,15 +19,15 @@ dynamic_cast < type-id > ( expression )
2019

2120
The `type-id` must be a pointer or a reference to a previously defined class type or a "pointer to void". The type of `expression` must be a pointer if `type-id` is a pointer, or an l-value if `type-id` is a reference.
2221

23-
See [static_cast](../cpp/static-cast-operator.md) for an explanation of the difference between static and dynamic casting conversions, and when it is appropriate to use each.
22+
See [static_cast](../cpp/static-cast-operator.md) for an explanation of the difference between static and dynamic casting conversions, and when it's appropriate to use each.
2423

2524
There are two breaking changes in the behavior of **`dynamic_cast`** in managed code:
2625

2726
- **`dynamic_cast`** to a pointer to the underlying type of a boxed enum will fail at runtime, returning 0 instead of the converted pointer.
2827

29-
- **`dynamic_cast`** will no longer throw an exception when `type-id` is an interior pointer to a value type, with the cast failing at runtime. The cast will now return the 0 pointer value instead of throwing.
28+
- **`dynamic_cast`** will no longer throw an exception when `type-id` is an interior pointer to a value type; instead, the cast fails at runtime. The cast returns the 0 pointer value instead of throwing.
3029

31-
If `type-id` is a pointer to an unambiguous accessible direct or indirect base class of `expression`, a pointer to the unique subobject of type `type-id` is the result. For example:
30+
If `type-id` is a pointer to an unambiguous accessible direct or indirect base class of `expression`, then a pointer to the unique subobject of type `type-id` is the result. For example:
3231

3332
```cpp
3433
// dynamic_cast_1.cpp
@@ -45,7 +44,7 @@ void f(D* pd) {
4544
}
4645
```
4746
48-
This type of conversion is called an "upcast" because it moves a pointer up a class hierarchy, from a derived class to a class it is derived from. An upcast is an implicit conversion.
47+
This type of conversion is called an "upcast" because it moves a pointer up a class hierarchy, from a derived class to a class it's derived from. An upcast is an implicit conversion.
4948
5049
If `type-id` is void*, a run-time check is made to determine the actual type of `expression`. The result is a pointer to the complete object pointed to by `expression`. For example:
5150
@@ -66,7 +65,7 @@ void f() {
6665
}
6766
```
6867

69-
If `type-id` is not void*, a run-time check is made to see if the object pointed to by `expression` can be converted to the type pointed to by `type-id`.
68+
If `type-id` isn't `void*`, a run-time check is made to see if the object pointed to by `expression` can be converted to the type pointed to by `type-id`.
7069

7170
If the type of `expression` is a base class of the type of `type-id`, a run-time check is made to see if `expression` actually points to a complete object of the type of `type-id`. If this is true, the result is a pointer to a complete object of the type of `type-id`. For example:
7271

@@ -114,8 +113,9 @@ int main() {
114113
}
115114
```
116115

117-
![Class hierarchy that shows multiple inheritance.](../cpp/media/vc39011.gif "Class hierarchy that shows multiple inheritance") <br/>
118-
Class hierarchy that shows multiple inheritance
116+
:::image type="complex" source="../cpp/media/vc39011.gif" alt-text="Diagram that shows multiple inheritance.":::
117+
The diagram shows a class hierarchy with A as a base class of B which is a base class of D. A is also a base class for C, which is a base class for D. Class D inherits from both B and C.
118+
:::image-end:::
119119

120120
A pointer to an object of type `D` can be safely cast to `B` or `C`. However, if `D` is cast to point to an `A` object, which instance of `A` would result? This would result in an ambiguous casting error. To get around this problem, you can perform two unambiguous casts. For example:
121121

@@ -137,14 +137,18 @@ void f() {
137137
138138
Further ambiguities can be introduced when you use virtual base classes. Consider the class hierarchy shown in the following figure.
139139
140-
![Class hierarchy that shows virtual base classes.](../cpp/media/vc39012.gif "Class hierarchy that shows virtual base classes") <br/>
140+
:::image type="complex" source="../cpp/media/vc39012.gif" alt-text="Diagram of a class hierarchy that shows virtual base classes.":::
141+
The diagram shows the classes A, B, C, D, and E arranged as follows: Class A is a base class of B. Classes C and E each derive from B. Class E also inherits from D, which inherits from class B, which inherits from class A.
142+
:::image-end:::
141143
Class hierarchy that shows virtual base classes
142144
143-
In this hierarchy, `A` is a virtual base class. Given an instance of class `E` and a pointer to the `A` subobject, a **`dynamic_cast`** to a pointer to `B` will fail due to ambiguity. You must first cast back to the complete `E` object, then work your way back up the hierarchy, in an unambiguous manner, to reach the correct `B` object.
145+
In this hierarchy, `A` is a virtual base class. Given an instance of class `E` and a pointer to the `A` subobject, a **`dynamic_cast`** to a pointer to `B` fails due to ambiguity. You must first cast back to the complete `E` object, then work your way back up the hierarchy, in an unambiguous manner, to reach the correct `B` object.
144146
145147
Consider the class hierarchy shown in the following figure.
146148
147-
![Class hierarchy that shows duplicate base classes.](../cpp/media/vc39013.gif "Class hierarchy that shows duplicate base classes") <br/>
149+
:::image type="complex" source="../cpp/media/vc39013.gif" alt-text="Diagram of a class hierarchy that shows duplicate base classes.":::
150+
The diagram shows the classes A, B, C, D, and E arranged as follows: Class B derives from Class A. Class C derives from class A. class D derives from class B. Class E derives from class C, which derives from class A. In this case, the duplicate base class is class A, which is directly or indirectly inherited by all the other classes. Class A is inherited directly by classes B and C, and indirectly by class D via class B, and indirectly by class E via class C, and indirectly in class D via class B.
151+
:::image-end:::
148152
Class hierarchy that shows duplicate base classes
149153
150154
Given an object of type `E` and a pointer to the `D` subobject, to navigate from the `D` subobject to the left-most `A` subobject, three conversions can be made. You can perform a **`dynamic_cast`** conversion from the `D` pointer to an `E` pointer, then a conversion (either **`dynamic_cast`** or an implicit conversion) from `E` to `B`, and finally an implicit conversion from `B` to `A`. For example:
@@ -165,9 +169,9 @@ void f(D* pd) {
165169
}
166170
```
167171

168-
The **`dynamic_cast`** operator can also be used to perform a "cross cast." Using the same class hierarchy, it is possible to cast a pointer, for example, from the `B` subobject to the `D` subobject, as long as the complete object is of type `E`.
172+
The **`dynamic_cast`** operator can also be used to perform a "cross cast." Using the same class hierarchy, it's possible to cast a pointer, for example, from the `B` subobject to the `D` subobject, as long as the complete object is of type `E`.
169173

170-
Considering cross casts, it is actually possible to do the conversion from a pointer to `D` to a pointer to the left-most `A` subobject in just two steps. You can perform a cross cast from `D` to `B`, then an implicit conversion from `B` to `A`. For example:
174+
Considering cross casts, it's possible to do the conversion from a pointer to `D` to a pointer to the left-most `A` subobject in just two steps. You can perform a cross cast from `D` to `B`, then an implicit conversion from `B` to `A`. For example:
171175

172176
```cpp
173177
// dynamic_cast_6.cpp
@@ -186,7 +190,7 @@ void f(D* pd) {
186190
187191
A null pointer value is converted to the null pointer value of the destination type by **`dynamic_cast`**.
188192
189-
When you use `dynamic_cast < type-id > ( expression )`, if `expression` cannot be safely converted to type `type-id`, the run-time check causes the cast to fail. For example:
193+
When you use `dynamic_cast < type-id > ( expression )`, if `expression` can't be safely converted to type `type-id`, the run-time check causes the cast to fail. For example:
190194
191195
```cpp
192196
// dynamic_cast_7.cpp
@@ -201,15 +205,15 @@ void f() {
201205
}
202206
```
203207

204-
The value of a failed cast to pointer type is the null pointer. A failed cast to reference type throws a [bad_cast Exception](../cpp/bad-cast-exception.md). If `expression` does not point to or reference a valid object, a `__non_rtti_object` exception is thrown.
208+
The value of a failed cast to pointer type is the null pointer. A failed cast to reference type throws a [bad_cast Exception](../cpp/bad-cast-exception.md). If `expression` doesn't point to or reference a valid object, a `__non_rtti_object` exception is thrown.
205209

206210
See [typeid](../cpp/typeid-operator.md) for an explanation of the `__non_rtti_object` exception.
207211

208212
## Example
209213

210214
The following sample creates the base class (struct A) pointer, to an object (struct C). This, plus the fact there are virtual functions, enables runtime polymorphism.
211215

212-
The sample also calls a non-virtual function in the hierarchy.
216+
The sample also calls a nonvirtual function in the hierarchy.
213217

214218
```cpp
215219
// dynamic_cast_8.cpp
@@ -270,7 +274,7 @@ int main() {
270274
C ConStack;
271275
Globaltest(ConStack);
272276

273-
// will fail because B knows nothing about C
277+
// fails because B knows nothing about C
274278
B BonStack;
275279
Globaltest(BonStack);
276280
}

0 commit comments

Comments
 (0)