Skip to content

Commit e89e164

Browse files
authored
Merge pull request #5131 from MicrosoftDocs/FromPublicMasterBranch
Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main)
2 parents 7d1200d + 803b891 commit e89e164

File tree

53 files changed

+96
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+96
-91
lines changed

docs/atl-mfc-shared/cstring-argument-passing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ When you define a class interface, you must determine the argument-passing conve
1414

1515
## <a name="_core_strings_as_function_inputs"></a> Strings as Function Inputs
1616

17-
The most efficient and secure way to use a `CString` object in called functions is to pass a `CString` object to the function. Despite the name, a `CString` object doesn't store a string internally as a C-style string that has a `NULL` terminator. Instead, a `CString` object keeps careful track of the number of characters it has. Having `CString` provide a `LPCTSTR` pointer to a `NULL`-terminated string is a small amount of work that can become significant if your code has to do it constantly. The result is temporary because any change to the `CString` contents invalidates old copies of the `LPCTSTR` pointer.
17+
The most efficient and secure way to use a `CString` object in called functions is to pass a `CString` object to the function. Despite the name, a `CString` object doesn't store a string internally as a C-style string that has a `NULL` terminator. Instead, a `CString` object keeps careful track of the number of characters it has. Having `CString` provide an `LPCTSTR` pointer to a `NULL`-terminated string is a small amount of work that can become significant if your code has to do it constantly. The result is temporary because any change to the `CString` contents invalidates old copies of the `LPCTSTR` pointer.
1818

1919
It does make sense in some cases to provide a C-style string. For example, there can be a situation where a called function is written in C and doesn't support objects. In this case, coerce the `CString` parameter to `LPCTSTR`, and the function will get a C-style `NULL`-terminated string. You can also go the other direction and create a `CString` object by using the `CString` constructor that accepts a C-style string parameter.
2020

docs/atl-mfc-shared/exporting-string-classes-using-cstringt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To resolve this problem, do the following:
2727

2828
Export `CStringA` and `CStringW` (and the necessary base classes) from MFC90.DLL. Projects that include MFC will always use the MFC DLL exported `CStringA` and `CStringW`, as in previous MFC implementations.
2929

30-
Then create a exportable derived class using the `CStringT` template, as `CStringT_Exported` is below, for example:
30+
Then create an exportable derived class using the `CStringT` template, as `CStringT_Exported` is below, for example:
3131

3232
[!code-cpp[NVC_MFC_DLL#7](../atl-mfc-shared/codesnippet/cpp/exporting-string-classes-using-cstringt_2.cpp)]
3333

docs/atl-mfc-shared/reference/classes-shared-by-mfc-and-atl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The following table lists the classes shared between MFC and ATL.
2121
|[CRect](../../atl-mfc-shared/reference/crect-class.md)|A class similar to a Windows [RECT](/windows/win32/api/windef/ns-windef-rect) structure that also includes member functions to manipulate `CRect` objects and Windows `RECT` structures.|atltypes.h|
2222
|[CSimpleStringT](../../atl-mfc-shared/reference/csimplestringt-class.md)|Represents a `CSimpleStringT` object.|atlsimpstr.h|
2323
|[CSize](../../atl-mfc-shared/reference/csize-class.md)|A class similar to the Windows [SIZE](/windows/win32/api/windef/ns-windef-size) structure, which implements a relative coordinate or position.|atltypes.h|
24-
|[CStrBufT](../../atl-mfc-shared/reference/cstrbuft-class.md)|Provides automatic resource cleanup for `GetBuffer` and `ReleaseBuffer` calls on a existing `CStringT` object.|atlsimpstr.h|
24+
|[CStrBufT](../../atl-mfc-shared/reference/cstrbuft-class.md)|Provides automatic resource cleanup for `GetBuffer` and `ReleaseBuffer` calls on an existing `CStringT` object.|atlsimpstr.h|
2525
|[CStringData](../../atl-mfc-shared/reference/cstringdata-class.md)|Represents the data of a string object.|atlsimpstr.h|
2626
|[CStringT](../../atl-mfc-shared/reference/cstringt-class.md)|Represents a `CStringT` object.|cstringt.h (MFC dependent) atlstr.h (MFC independent)|
2727
|[CTime](../../atl-mfc-shared/reference/ctime-class.md)|Represents an absolute time and date.|atltime.h|

docs/build/open-folder-projects-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ This configuration inherits the environment variables of the Visual Studio [x64
7474
7575
## Default configuration for MinGW-w64
7676

77-
If you add the MinGW-W64 configuration, the JSON looks this this:
77+
If you add the MinGW-W64 configuration, the JSON looks this:
7878

7979
```json
8080
{

docs/build/reference/filealign.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.assetid: c1017a35-8d71-4ad9-934b-a3e3ea037fa0
88
---
99
# /FILEALIGN (Align sections in files)
1010

11-
The **/FILEALIGN** linker option lets you specify the alignment of sections written to your output file as a multiple of an specified size.
11+
The **/FILEALIGN** linker option lets you specify the alignment of sections written to your output file as a multiple of a specified size.
1212

1313
## Syntax
1414

docs/build/walkthrough-build-debug-wsl2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ If you have a MSBuild-based Linux project, then you can upgrade to the WSL 2 too
128128

129129
If you're targeting a WSL 2 distribution and you don't want to use the WSL 2 toolset, then in the **Platform Toolset** dropdown, select the **GCC for Windows Subsystem for Linux** or **Clang for Windows Subsystem for Linux** toolset. If either of these toolsets are selected, Visual Studio won't maintain a copy of your source files in the WSL file system and will instead access source files over the mounted Windows drive (`/mnt/`…). System headers are still automatically copied to the Windows file system to provide a native IntelliSense experience. Customize the headers that are included or excluded from this copy in **Property Pages** > **General**.
130130

131-
In most cases, it's best to use the WSL 2 toolset with WSL 2 distributions because WSL 2 is slower when project files are stored in the Windows file system. To to learn more, see [Comparing WSL 1 and WSL 2](/windows/wsl/compare-versions).
131+
In most cases, it's best to use the WSL 2 toolset with WSL 2 distributions because WSL 2 is slower when project files are stored in the Windows file system. To learn more, see [Comparing WSL 1 and WSL 2](/windows/wsl/compare-versions).
132132
133133
## See also
134134

docs/c-language/escape-sequences.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Note that the question mark preceded by a backslash (**\\?**) specifies a litera
3434

3535
**Microsoft Specific**
3636

37-
If a backslash precedes a character that does not appear in the table, the compiler handles the undefined character as the character itself. For example, `\c` is treated as an `c`.
37+
If a backslash precedes a character that does not appear in the table, the compiler handles the undefined character as the character itself. For example, `\c` is treated as a `c`.
3838

3939
**END Microsoft Specific**
4040

docs/code-quality/c26444.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ An unnamed variable declaration creates a temporary object that is discarded at
1818
## Remarks
1919

2020
- This rule detects types with a hand-written destructor or a compiler-generated destructor that transitively calls a hand-written destructor.
21-
- This rule can flag code that invokes a nontrivial constructor of a RAII type.
21+
- This rule can flag code that invokes a nontrivial constructor of an RAII type.
2222
- The logic skips temporaries if they're used in higher-level expressions. One example is temporaries that are passed as arguments or used to invoke a function.
2323

2424
Code analysis name: `NO_UNNAMED_RAII_OBJECTS`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ Because of the way the code analysis rules get loaded within Visual Studio 2015,
321321

322322
1. Select the Microsoft.CppCoreCheck package and then choose the **Install** button to add the rules to your project.
323323

324-
The NuGet package adds a 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.
325325

326326
::: moniker-end
327327

docs/code-quality/walkthrough-analyzing-c-cpp-code-for-defects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ In this walkthrough, you'll:
9090

9191
C6230: Implicit cast between semantically different types: using HRESULT in a Boolean context.
9292

93-
The code editor displays the line that caused the warning inside the function `bool ProcessDomain()`. This warning indicates that a `HRESULT` is being used in an 'if' statement where a Boolean result is expected. It's typically a mistake, because when the `S_OK` HRESULT is returned from a function it indicates success, but when converted into a boolean value it evaluates to **`false`**.
93+
The code editor displays the line that caused the warning inside the function `bool ProcessDomain()`. This warning indicates that an `HRESULT` is being used in an 'if' statement where a Boolean result is expected. It's typically a mistake, because when the `S_OK` HRESULT is returned from a function it indicates success, but when converted into a boolean value it evaluates to **`false`**.
9494

9595
1. Correct this warning by using the `SUCCEEDED` macro, which converts to **`true`** when a `HRESULT` return value indicates success. Your code should resemble the following code:
9696

docs/cpp/arrays-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ It specifies an array of type **`int`**, conceptually arranged in a two-dimensio
163163

164164
:::image type="content" source="../cpp/media/vc38rc1.gif" alt-text="Conceptual layout of a multidimensional array.":::
165165

166-
The image is a grid 7 cells wide and 5 cells high. Each cell contains the index of the cell. The first cell index is labeled 0,0. The next cell in that row is 0,1 and so on to the last cell in that row which is 0,6. The next row starts with the index 1,0. The cell after that has an index of 1,1. The last cell in that row is 1,6. This pattern repeats until the last row, which starts with the index 4,0. The the last cell in the last row has an index of 4,6.
166+
The image is a grid 7 cells wide and 5 cells high. Each cell contains the index of the cell. The first cell index is labeled 0,0. The next cell in that row is 0,1 and so on to the last cell in that row which is 0,6. The next row starts with the index 1,0. The cell after that has an index of 1,1. The last cell in that row is 1,6. This pattern repeats until the last row, which starts with the index 4,0. The last cell in the last row has an index of 4,6.
167167
:::image-end
168168

169169
You can declare multidimensioned arrays that have an initializer list (as described in [Initializers](../cpp/initializers.md)). In these declarations, the constant expression that specifies the bounds for the first dimension can be omitted. For example:

docs/cpp/clrcall.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ When `/clr` (not `/clr:pure` or `/clr:safe`) is used and **__clrcall** is not us
2020

2121
[/clr (Common Language Runtime Compilation)](../build/reference/clr-common-language-runtime-compilation.md) implies that all functions and function pointers are **__clrcall** and the compiler will not permit a function inside the compiland to be marked anything other than **__clrcall**. When **/clr:pure** is used, **__clrcall** can only be specified on function pointers and external declarations.
2222

23-
You can directly call **__clrcall** functions from existing C++ code that was compiled by using **/clr** as long as that function has an MSIL implementation. **__clrcall** functions cannot be called directly from functions that have inline asm and call CPU-specific intrinisics, for example, even if those functions are compiled with `/clr`.
23+
You can directly call **__clrcall** functions from existing C++ code that was compiled by using **/clr** as long as that function has an MSIL implementation. **__clrcall** functions cannot be called directly from functions that have inline asm and call CPU-specific intrinsics, for example, even if those functions are compiled with `/clr`.
2424

2525
**__clrcall** function pointers are only meant to be used in the application domain in which they were created. Instead of passing **__clrcall** function pointers across application domains, use <xref:System.CrossAppDomainDelegate>. For more information, see [Application Domains and Visual C++](../dotnet/application-domains-and-visual-cpp.md).
2626

docs/cpp/destructors-cpp.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,42 @@ Consider the following declaration of a `String` class:
1414

1515
```cpp
1616
// spec1_destructors.cpp
17-
#include <string>
18-
19-
class String {
20-
public:
21-
String( char *ch ); // Declare constructor
22-
~String(); // and destructor.
23-
private:
24-
char *_text;
25-
size_t sizeOfText;
17+
#include <string> // strlen()
18+
19+
class String
20+
{
21+
public:
22+
String(const char* ch); // Declare the constructor
23+
~String(); // Declare the destructor
24+
private:
25+
char* _text{nullptr};
2626
};
2727

28-
// Define the constructor.
29-
String::String( char *ch ) {
30-
sizeOfText = strlen( ch ) + 1;
28+
// Define the constructor
29+
String::String(const char* ch)
30+
{
31+
size_t sizeOfText = strlen(ch) + 1; // +1 to account for trailing NULL
3132

32-
// Dynamically allocate the correct amount of memory.
33-
_text = new char[ sizeOfText ];
33+
// Dynamically allocate the correct amount of memory.
34+
_text = new char[sizeOfText];
3435

35-
// If the allocation succeeds, copy the initialization string.
36-
if( _text )
37-
strcpy_s( _text, sizeOfText, ch );
36+
// If the allocation succeeds, copy the initialization string.
37+
if (_text)
38+
{
39+
strcpy_s(_text, sizeOfText, ch);
40+
}
3841
}
3942

4043
// Define the destructor.
41-
String::~String() {
42-
// Deallocate the memory that was previously reserved
43-
// for this string.
44-
delete[] _text;
44+
String::~String()
45+
{
46+
// Deallocate the memory that was previously reserved for the string.
47+
delete[] _text;
4548
}
4649

47-
int main() {
48-
String str("The piper in the glen...");
50+
int main()
51+
{
52+
String str("We love C++");
4953
}
5054
```
5155

docs/cpp/enumerations-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ hand = account_num; // error C2440: '=' : cannot convert from 'int' to 'Suit'
137137
A cast is required to convert an **`int`** to a scoped or unscoped enumerator. However, you can promote an unscoped enumerator to an integer value without a cast.
138138

139139
```cpp
140-
int account_num = Hearts; //OK if Hearts is in a unscoped enum
140+
int account_num = Hearts; //OK if Hearts is in an unscoped enum
141141
```
142142

143143
Using implicit conversions in this way can lead to unintended side-effects. To help eliminate programming errors associated with unscoped enums, scoped enum values are strongly typed. Scoped enumerators must be qualified by the enum type name (identifier) and can't be implicitly converted, as shown in the following example:

docs/cpp/namespaces-cpp.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The **`using`** directive allows all the names in a **`namespace`** to be used w
6464
Typically, you declare a namespace in a header file. If your function implementations are in a separate file, then qualify the function names, as in this example.
6565
6666
```cpp
67-
//contosoData.h
67+
// contosoData.h
6868
#pragma once
6969
namespace ContosoDataServer
7070
{
@@ -144,7 +144,7 @@ Ordinary nested namespaces can be used to encapsulate internal implementation de
144144
In contrast to an ordinary nested namespace, members of an inline namespace are treated as members of the parent namespace. This characteristic enables argument dependent lookup on overloaded functions to work on functions that have overloads in a parent and a nested inline namespace. It also enables you to declare a specialization in a parent namespace for a template that is declared in the inline namespace. The following example shows how external code binds to the inline namespace by default:
145145

146146
```cpp
147-
//Header.h
147+
// Header.h
148148
#include <string>
149149

150150
namespace Test
@@ -160,6 +160,7 @@ namespace Test
160160
}
161161
}
162162

163+
// main.cpp
163164
#include "header.h"
164165
#include <string>
165166
#include <iostream>

docs/cpp/static-assert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static_assert( constant-expression ); // C++17 (Visual Studio 2017 and later)
2424
An integral constant expression that can be converted to a Boolean. If the evaluated expression is zero (false), the *string-literal* parameter is displayed and the compilation fails with an error. If the expression is nonzero (true), the **`static_assert`** declaration has no effect.
2525

2626
*string-literal*\
27-
An message that is displayed if the *constant-expression* parameter is zero. The message is a string of characters in the [base character set](../c-language/ascii-character-set.md) of the compiler; that is, not [multibyte or wide characters](../c-language/multibyte-and-wide-characters.md).
27+
A message that is displayed if the *constant-expression* parameter is zero. The message is a string of characters in the [base character set](../c-language/ascii-character-set.md) of the compiler; that is, not [multibyte or wide characters](../c-language/multibyte-and-wide-characters.md).
2828

2929
## Remarks
3030

docs/cpp/templates-and-name-resolution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ A type is dependent if it depends on the template arguments. Specifically, a typ
6464

6565
## Type Dependence and Value Dependence
6666

67-
Names and expressions dependent on a template parameter are categorized as type dependent or value dependent, depending on whether the template parameter is a type parameter or a value parameter. Also, any identifiers declared in a template with a type dependent on the template argument are considered value dependent, as is a integral or enumeration type initialized with a value-dependent expression.
67+
Names and expressions dependent on a template parameter are categorized as type dependent or value dependent, depending on whether the template parameter is a type parameter or a value parameter. Also, any identifiers declared in a template with a type dependent on the template argument are considered value dependent, as is an integral or enumeration type initialized with a value-dependent expression.
6868

6969
Type-dependent and value-dependent expressions are expressions that involve variables that are type dependent or value dependent. These expressions can have semantics that differ, depending on the parameters used for the template.
7070

docs/cpp/tutorial-named-modules-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ module; // optional. Defines the beginning of the global module fragment
271271
export module [module-name]; // Required. Marks the beginning of the module preamble
272272

273273
// import statements go here. They're available to all files that belong to the named module
274-
// Put #includes in in the global module fragment, above
274+
// Put #includes in the global module fragment, above
275275

276276
// After any import statements, the module purview begins here
277277
// Put exported functions, types, and templates here

docs/cpp/variant-t-variant-t.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ A `BYTE` value to be copied into the new `_variant_t` object.
171171
A **`char`** value to be copied into the new `_variant_t` object.
172172

173173
*`usSrc`*\
174-
A **`unsigned short`** value to be copied into the new `_variant_t` object.
174+
An **`unsigned short`** value to be copied into the new `_variant_t` object.
175175

176176
*`ulSrc`*\
177177
A **`unsigned long`** value to be copied into the new `_variant_t` object.

docs/cppcx/casting-c-cx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ If you use **`reinterpret_cast`** to convert from one Windows Runtime interface
9797

9898
- Conversions between a Windows Runtime interface type and its equivalent ABI type are always safe—that is, `IBuffer^` to `ABI::IBuffer*`.
9999

100-
- A Windows Runtime runtime class should always be converted to `IInspectable*` or its default interface, if that is known.
100+
- A Windows Runtime class should always be converted to `IInspectable*` or its default interface, if that is known.
101101

102102
- After you convert to ABI types, you own the lifetime of the type and must follow the COM rules. We recommend that you use `WRL::ComPtr` to simplify lifetime management of ABI pointers.
103103

0 commit comments

Comments
 (0)