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/cpp/additional-termination-considerations.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ ms.author: "mblome"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# Additional Termination Considerations
15
-
You can terminate a C++ program by using **exit**, `return`, or **abort**. You can add exit processing using the `atexit` function. These are discussed in the following sections.
15
+
You can terminate a C++ program by using **exit**, **return**, or **abort**. You can add exit processing using the `atexit` function. These are discussed in the following sections.
16
16
17
17
## See Also
18
18
[Startup and Termination](../cpp/startup-and-termination-cpp.md)
Copy file name to clipboardExpand all lines: docs/cpp/aliases-and-typedefs-cpp.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ ptr<int> ptr_int;
80
80
```
81
81
82
82
## Example
83
-
The following example demonstrates how to use an alias template with a custom allocator—in this case, an integer vector type. You can substitute any type for `int` to create a convenient alias to hide the complex parameter lists in your main functional code. By using the custom allocator throughout your code you can improve readability and reduce the risk of introducing bugs caused by typos.
83
+
The following example demonstrates how to use an alias template with a custom allocator—in this case, an integer vector type. You can substitute any type for **int** to create a convenient alias to hide the complex parameter lists in your main functional code. By using the custom allocator throughout your code you can improve readability and reduce the risk of introducing bugs caused by typos.
84
84
85
85
```cpp
86
86
#include<stdlib.h>
@@ -232,7 +232,7 @@ typedef char CHAR, *PSTR;
232
232
typedef void DRAWF( int, int );
233
233
```
234
234
235
-
After the above `typedef` statement, the declaration
235
+
After the above **typedef** statement, the declaration
236
236
237
237
```
238
238
DRAWF box;
@@ -284,7 +284,7 @@ typedef char CHAR;
284
284
#include"file2.h"// OK
285
285
```
286
286
287
-
The program *PROG.CPP* includes two header files, both of which contain `typedef` declarations for the name `CHAR`. As long as both declarations refer to the same type, such redeclaration is acceptable.
287
+
The program *PROG.CPP* includes two header files, both of which contain **typedef** declarations for the name `CHAR`. As long as both declarations refer to the same type, such redeclaration is acceptable.
288
288
289
289
A **typedef** cannot redefine a name that was previously declared as a different type. Therefore, if *FILE2.H* contains
290
290
@@ -343,7 +343,7 @@ typedef struct {
343
343
} POINT;
344
344
```
345
345
346
-
The preceding example declares a class named `POINT` using the unnamed class `typedef` syntax. `POINT` is treated as a class name; however, the following restrictions apply to names introduced this way:
346
+
The preceding example declares a class named `POINT` using the unnamed class **typedef** syntax. `POINT` is treated as a class name; however, the following restrictions apply to names introduced this way:
347
347
348
348
- The name (the synonym) cannot appear after a **class**, **struct**, or **union** prefix.
Copy file name to clipboardExpand all lines: docs/cpp/align-cpp.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,13 +32,13 @@ Writing applications that use the latest processor instructions introduces some
32
32
33
33
For information about how to return a value of type `size_t` that is the alignment requirement of the type, see [__alignof](../cpp/alignof-operator.md). For information about how to declare unaligned pointers when targeting 64-bit processors, see [__unaligned](../cpp/unaligned.md).
34
34
35
-
You can use `__declspec(align(#))` when you define a `struct`, `union`, or `class`, or when you declare a variable.
35
+
You can use `__declspec(align(#))` when you define a **struct**, **union**, or **class**, or when you declare a variable.
36
36
37
37
The compiler does not guarantee or attempt to preserve the alignment attribute of data during a copy or data transform operation. For example, [memcpy](../c-runtime-library/reference/memcpy-wmemcpy.md) can copy a struct declared with `__declspec(align(#))` to any location. Note that ordinary allocators—for example, [malloc](../c-runtime-library/reference/malloc.md), C++ [operator new](new-operator-cpp.md), and the Win32 allocators—return memory that is usually not sufficiently aligned for `__declspec(align(#))` structures or arrays of structures. To guarantee that the destination of a copy or data transformation operation is correctly aligned, use [_aligned_malloc](../c-runtime-library/reference/aligned-malloc.md), or write your own allocator.
38
38
39
39
You cannot specify alignment for function parameters. When data that has an alignment attribute is passed by value on the stack, its alignment is controlled by the calling convention. If data alignment is important in the called function, copy the parameter into correctly aligned memory before use.
40
40
41
-
Without `__declspec(align(#))`, the compiler generally aligns data on natural boundaries based on the target processor and the size of the data, up to 4-byte boundaries on 32-bit processors, and 8-byte boundaries on 64-bit processors. Data in classes or structures is aligned in the class or structure at the minimum of its natural alignment and the current packing setting (from #pragma `pack` or the **/Zp** compiler option).
41
+
Without `__declspec(align(#))`, the compiler generally aligns data on natural boundaries based on the target processor and the size of the data, up to 4-byte boundaries on 32-bit processors, and 8-byte boundaries on 64-bit processors. Data in classes or structures is aligned in the class or structure at the minimum of its natural alignment and the current packing setting (from #pragma **pack** or the **/Zp** compiler option).
42
42
43
43
This example demonstrates the use of `__declspec(align(#))`:
44
44
@@ -87,7 +87,7 @@ The following examples show how `__declspec(align(#))` affects the size and alig
87
87
#define CACHE_ALIGN __declspec(align(CACHE_LINE))
88
88
```
89
89
90
-
In this example, the `S1` structure is defined by using `__declspec(align(32))`. All uses of `S1` for a variable definition or in other type declarations are 32-byte aligned. `sizeof(struct S1)` returns 32, and `S1` has 16 padding bytes following the 16 bytes required to hold the four integers. Each `int` member requires 4-byte alignment, but the alignment of the structure itself is declared to be 32. Therefore, the overall alignment is 32.
90
+
In this example, the `S1` structure is defined by using `__declspec(align(32))`. All uses of `S1` for a variable definition or in other type declarations are 32-byte aligned. `sizeof(struct S1)` returns 32, and `S1` has 16 padding bytes following the 16 bytes required to hold the four integers. Each **int** member requires 4-byte alignment, but the alignment of the structure itself is declared to be 32. Therefore, the overall alignment is 32.
91
91
92
92
```cpp
93
93
structCACHE_ALIGN S1 { // cache align all instances of S1
@@ -167,7 +167,7 @@ void fn() {
167
167
}
168
168
```
169
169
170
-
The alignment when memory is allocated on the heap depends on which allocation function is called. For example, if you use `malloc`, the result depends on the operand size. If *arg* >= 8, the memory returned is 8 byte aligned. If *arg* < 8, the alignment of the memory returned is the first power of 2 less than *arg*. For example, if you use malloc(7), the alignment is 4 bytes.
170
+
The alignment when memory is allocated on the heap depends on which allocation function is called. For example, if you use **malloc**, the result depends on the operand size. If *arg* >= 8, the memory returned is 8 byte aligned. If *arg* < 8, the alignment of the memory returned is the first power of 2 less than *arg*. For example, if you use malloc(7), the alignment is 4 bytes.
171
171
172
172
## <aname="vclrf_declspecaligntypedef"></a> Defining New Types with __declspec(align(#))
## <aname="vclrfhowalignworkswithdatapacking"></a> How align Works with Data Packing
209
209
210
-
The **/Zp** compiler option and the `pack` pragma have the effect of packing data for structure and union members.This example shows how **/Zp** and `__declspec(align(#))` work together:
210
+
The **/Zp** compiler option and the **pack** pragma have the effect of packing data for structure and union members.This example shows how **/Zp** and `__declspec(align(#))` work together:
211
211
212
212
```c[[]]
213
213
struct S {
@@ -220,7 +220,7 @@ struct S {
220
220
};
221
221
```
222
222
223
-
The following table lists the offset of each member under a variety of **/Zp** (or #pragma `pack`) values, showing how the two interact.
223
+
The following table lists the offset of each member under a variety of **/Zp** (or #pragma **pack**) values, showing how the two interact.
Copy file name to clipboardExpand all lines: docs/cpp/anonymous-class-types.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ ms.author: "mblome"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# Anonymous Class Types
15
-
Classes can be anonymous — that is, they can be declared without an *identifier*. This is useful when you replace a class name with a `typedef` name, as in the following:
15
+
Classes can be anonymous — that is, they can be declared without an *identifier*. This is useful when you replace a class name with a **typedef** name, as in the following:
16
16
17
17
```
18
18
typedef struct
@@ -23,7 +23,7 @@ typedef struct
23
23
```
24
24
25
25
> [!NOTE]
26
-
> The use of anonymous classes shown in the previous example is useful for preserving compatibility with existing C code. In some C code, the use of `typedef` in conjunction with anonymous structures is prevalent.
26
+
> The use of anonymous classes shown in the previous example is useful for preserving compatibility with existing C code. In some C code, the use of **typedef** in conjunction with anonymous structures is prevalent.
27
27
28
28
Anonymous classes are also useful when you want a reference to a class member to appear as though it were not contained in a separate class, as in the following:
Copy file name to clipboardExpand all lines: docs/cpp/argument-definitions.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,25 +22,25 @@ int wmain( int argc, wchar_t* argv[], wchar_t* envp[]);
22
22
23
23
allow convenient command-line parsing of arguments and, optionally, access to environment variables. The argument definitions are as follows:
24
24
25
-
`argc`
26
-
An integer that contains the count of arguments that follow in `argv`. The `argc` parameter is always greater than or equal to 1.
25
+
*argc*
26
+
An integer that contains the count of arguments that follow in *argv*. The *argc* parameter is always greater than or equal to 1.
27
27
28
-
`argv`
29
-
An array of null-terminated strings representing command-line arguments entered by the user of the program. By convention, `argv`**[0]** is the command with which the program is invoked, `argv`**[1]** is the first command-line argument, and so on, until `argv`**[**`argc`**]**, which is always **NULL**. See [Customizing Command Line Processing](../cpp/customizing-cpp-command-line-processing.md) for information on suppressing command-line processing.
28
+
*argv*
29
+
An array of null-terminated strings representing command-line arguments entered by the user of the program. By convention, `argv`**[0]** is the command with which the program is invoked, `argv`**[1]** is the first command-line argument, and so on, until `argv`**[**`argc`**]**, which is always NULL. See [Customizing Command Line Processing](../cpp/customizing-cpp-command-line-processing.md) for information on suppressing command-line processing.
30
30
31
31
The first command-line argument is always `argv`**[1]** and the last one is `argv`**[**`argc` - 1**]**.
32
32
33
33
> [!NOTE]
34
34
> By convention, `argv`**[0]** is the command with which the program is invoked. However, it is possible to spawn a process using [CreateProcess](http://msdn.microsoft.com/library/windows/desktop/ms683197) and if you use both the first and second arguments (`lpApplicationName` and `lpCommandLine`), `argv`**[0]** may not be the executable name; use [GetModuleFileName](http://msdn.microsoft.com/library/windows/desktop/ms683197) to retrieve the executable name, and its fully-qualified path.
35
35
36
36
## Microsoft Specific
37
-
`envp`
38
-
The `envp` array, which is a common extension in many UNIX systems, is used in Microsoft C++. It is an array of strings representing the variables set in the user's environment. This array is terminated by a **NULL** entry. It can be declared as an array of pointers to **char (char**\*envp[]**)** or as a pointer to pointers to **char (char**\*\*envp**)**. If your program uses **wmain** instead of **main**, use the `wchar_t` data type instead of `char`. The environment block passed to **main** and **wmain** is a "frozen" copy of the current environment. If you subsequently change the environment via a call to **putenv** or `_wputenv`, the current environment (as returned by `getenv`/`_wgetenv` and the `_environ`/ `_wenviron` variable) will change, but the block pointed to by envp will not change. See [Customizing Command Line Processing](../cpp/customizing-cpp-command-line-processing.md) for information on suppressing environment processing. This argument is ANSI compatible in C, but not in C++.
37
+
*envp*
38
+
The *envp* array, which is a common extension in many UNIX systems, is used in Microsoft C++. It is an array of strings representing the variables set in the user's environment. This array is terminated by a NULL entry. It can be declared as an array of pointers to **char (char**\*envp[]**)** or as a pointer to pointers to **char (char**\*\*envp**)**. If your program uses **wmain** instead of **main**, use the **wchar_t** data type instead of **char**. The environment block passed to **main** and **wmain** is a "frozen" copy of the current environment. If you subsequently change the environment via a call to **putenv** or `_wputenv`, the current environment (as returned by `getenv`/`_wgetenv` and the `_environ`/ `_wenviron` variable) will change, but the block pointed to by envp will not change. See [Customizing Command Line Processing](../cpp/customizing-cpp-command-line-processing.md) for information on suppressing environment processing. This argument is ANSI compatible in C, but not in C++.
39
39
40
40
**END Microsoft Specific**
41
41
42
42
## Example
43
-
The following example shows how to use the `argc`, `argv`, and `envp` arguments to **main**:
43
+
The following example shows how to use the *argc*, *argv*, and *envp* arguments to **main**:
- A constant expression of integral type enclosed in brackets, **[].** If multiple dimensions are declared using additional brackets, the constant expression may be omitted on the first set of brackets.
38
+
- A constant expression of integral type enclosed in brackets, **[]**. If multiple dimensions are declared using additional brackets, the constant expression may be omitted on the first set of brackets.
3. An optional initializer. See [Initializers](../cpp/initializers.md).
43
43
44
-
The number of elements in the array is given by the constant expression. The first element in the array is the 0th element, and the last element is the (*n*-1) element, where *n* is the number of elements the array can contain. The *constant-expression* must be of an integral type and must be greater than 0. A zero-sized array is legal only when the array is the last field in a `struct` or **union** and when the Microsoft extensions (/Ze) are enabled.
44
+
The number of elements in the array is given by the constant expression. The first element in the array is the 0th element, and the last element is the (*n*-1) element, where *n* is the number of elements the array can contain. The *constant-expression* must be of an integral type and must be greater than 0. A zero-sized array is legal only when the array is the last field in a **struct** or **union** and when the Microsoft extensions (/Ze) are enabled.
45
45
46
46
The following example shows how to define an array at run time:
47
47
@@ -66,15 +66,15 @@ int main() {
66
66
}
67
67
```
68
68
69
-
Arrays are derived types and can therefore be constructed from any other derived or fundamental type except functions, references, and `void`.
69
+
Arrays are derived types and can therefore be constructed from any other derived or fundamental type except functions, references, and **void**.
70
70
71
71
Arrays constructed from other arrays are multidimensional arrays. These multidimensional arrays are specified by placing multiple bracketed constant expressions in sequence. For example, consider this declaration:
72
72
73
73
```
74
74
int i2[5][7];
75
75
```
76
76
77
-
It specifies an array of type `int`, conceptually arranged in a two-dimensional matrix of five rows and seven columns, as shown in the following figure:
77
+
It specifies an array of type **int**, conceptually arranged in a two-dimensional matrix of five rows and seven columns, as shown in the following figure:
78
78
79
79

Copy file name to clipboardExpand all lines: docs/cpp/assertion-and-user-supplied-messages-cpp.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ The C++ language supports three error handling mechanisms that help you debug yo
23
23
24
24
The `static_assert` declaration is especially useful for debugging templates because template arguments can be included in the user-specified expression.
25
25
26
-
- The [assert Macro, _assert, _wassert](../c-runtime-library/reference/assert-macro-assert-wassert.md) macro is in effect at run time. It evaluates a user-specified expression, and if the result is zero, the system issues a diagnostic message and closes your application. Many other macros, such as[_ASSERT](../c-runtime-library/reference/assert-asserte-assert-expr-macros.md) and `_ASSERTE`, resemble this macro but issue different system-defined or user-defined diagnostic messages.
26
+
- The [assert Macro, _assert, _wassert](../c-runtime-library/reference/assert-macro-assert-wassert.md) macro is in effect at run time. It evaluates a user-specified expression, and if the result is zero, the system issues a diagnostic message and closes your application. Many other macros, such as[_ASSERT](../c-runtime-library/reference/assert-asserte-assert-expr-macros.md) and _ASSERTE, resemble this macro but issue different system-defined or user-defined diagnostic messages.
Copy file name to clipboardExpand all lines: docs/cpp/assignment.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,11 @@ ms.workload: ["cplusplus"]
14
14
# Assignment
15
15
The assignment operator (**=**) is, strictly speaking, a binary operator. Its declaration is identical to any other binary operator, with the following exceptions:
16
16
17
-
- It must be a nonstatic member function. No `operator=` can be declared as a nonmember function.
17
+
- It must be a nonstatic member function. No **operator=** can be declared as a nonmember function.
18
18
19
19
- It is not inherited by derived classes.
20
20
21
-
- A default `operator=` function can be generated by the compiler for class types if none exists. (For more information about default `operator=` functions, see [Memberwise Assignment and Initialization](http://msdn.microsoft.com/en-us/94048213-8b49-4416-8069-b1b7a6f271f9).)
21
+
- A default **operator=** function can be generated by the compiler for class types if none exists. (For more information about default **operator=** functions, see [Memberwise Assignment and Initialization](http://msdn.microsoft.com/en-us/94048213-8b49-4416-8069-b1b7a6f271f9).)
22
22
23
23
The following example illustrates how to declare an assignment operator:
0 commit comments