Skip to content

Commit 53e42b3

Browse files
author
Michael Blome
committed
fixed merge conflicts
2 parents 11eda21 + 91fbb97 commit 53e42b3

1,351 files changed

Lines changed: 51608 additions & 66100 deletions

File tree

Some content is hidden

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

.openpublishing.redirection.json

Lines changed: 905 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Using C or C++ in __asm Blocks | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "06/25/2018"
55
ms.technology: ["cpp-masm"]
66
ms.topic: "conceptual"
77
dev_langs: ["C++"]
@@ -12,36 +12,39 @@ ms.author: "corob"
1212
ms.workload: ["cplusplus"]
1313
---
1414
# Using C or C++ in __asm Blocks
15-
## Microsoft Specific
16-
Because inline assembly instructions can be mixed with C or C++ statements, they can refer to C or C++ variables by name and use many other elements of those languages.
17-
18-
An `__asm` block can use the following language elements:
19-
20-
- Symbols, including labels and variable and function names
21-
22-
- Constants, including symbolic constants and `enum` members
23-
24-
- Macros and preprocessor directives
25-
26-
- Comments (both **/\* \*/** and **//** )
27-
28-
- Type names (wherever a MASM type would be legal)
29-
30-
- `typedef` names, generally used with operators such as **PTR** and **TYPE** or to specify structure or union members
31-
32-
Within an `__asm` block, you can specify integer constants with either C notation or assembler radix notation (0x100 and 100h are equivalent, for example). This allows you to define (using `#define`) a constant in C and then use it in both C or C++ and assembly portions of the program. You can also specify constants in octal by preceding them with a 0. For example, 0777 specifies an octal constant.
33-
34-
## What do you want to know more about?
35-
36-
- [Using Operators in __asm Blocks](../../assembler/inline/using-operators-in-asm-blocks.md)
37-
38-
- [Using C or C++ Symbols_in __asm Blocks](../../assembler/inline/using-c-or-cpp-symbols-in-asm-blocks.md)
39-
40-
- [Accessing C or C++ Data in __asm Blocks](../../assembler/inline/accessing-c-or-cpp-data-in-asm-blocks.md)
41-
42-
- [Writing Functions with Inline Assembly](../../assembler/inline/writing-functions-with-inline-assembly.md)
43-
44-
**END Microsoft Specific**
45-
46-
## See Also
47-
[Inline Assembler](../../assembler/inline/inline-assembler.md)
15+
16+
** Microsoft Specific **
17+
18+
Because inline assembly instructions can be mixed with C or C++ statements, they can refer to C or C++ variables by name and use many other elements of those languages.
19+
20+
An `__asm` block can use the following language elements:
21+
22+
- Symbols, including labels and variable and function names
23+
24+
- Constants, including symbolic constants and `enum` members
25+
26+
- Macros and preprocessor directives
27+
28+
- Comments (both __/\* \*/__ and __//__ )
29+
30+
- Type names (wherever a MASM type would be legal)
31+
32+
- `typedef` names, generally used with operators such as **PTR** and **TYPE** or to specify structure or union members
33+
34+
Within an `__asm` block, you can specify integer constants with either C notation or assembler radix notation (0x100 and 100h are equivalent, for example). This allows you to define (using `#define`) a constant in C and then use it in both C or C++ and assembly portions of the program. You can also specify constants in octal by preceding them with a 0. For example, 0777 specifies an octal constant.
35+
36+
## What do you want to know more about?
37+
38+
- [Using Operators in __asm Blocks](../../assembler/inline/using-operators-in-asm-blocks.md)
39+
40+
- [Using C or C++ Symbols_in __asm Blocks](../../assembler/inline/using-c-or-cpp-symbols-in-asm-blocks.md)
41+
42+
- [Accessing C or C++ Data in __asm Blocks](../../assembler/inline/accessing-c-or-cpp-data-in-asm-blocks.md)
43+
44+
- [Writing Functions with Inline Assembly](../../assembler/inline/writing-functions-with-inline-assembly.md)
45+
46+
**END Microsoft Specific**
47+
48+
## See also
49+
50+
[Inline Assembler](../../assembler/inline/inline-assembler.md)

docs/atl-mfc-shared/basic-cstring-operations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This topic explains the following basic [CString](../atl-mfc-shared/reference/cs
2424

2525
- [Converting CString objects](#_core_converting_cstring_objects)
2626

27-
`Class CString` is based on class template [CStringT Class](../atl-mfc-shared/reference/cstringt-class.md). `CString` is a `typedef` of `CStringT`. More exactly, `CString` is a `typedef` of an *explicit specialization* of `CStringT`, which is a common way to use a class template to define a class. Similarly defined classes are `CStringA` and `CStringW`.
27+
`Class CString` is based on class template [CStringT Class](../atl-mfc-shared/reference/cstringt-class.md). `CString` is a **typedef** of `CStringT`. More exactly, `CString` is a **typedef** of an *explicit specialization* of `CStringT`, which is a common way to use a class template to define a class. Similarly defined classes are `CStringA` and `CStringW`.
2828

2929
`CString`, `CStringA`, and `CStringW` are defined in atlstr.h. `CStringT` is defined in cstringt.h.
3030

@@ -56,10 +56,10 @@ This topic explains the following basic [CString](../atl-mfc-shared/reference/cs
5656

5757
[!code-cpp[NVC_ATLMFC_Utilities#185](../atl-mfc-shared/codesnippet/cpp/basic-cstring-operations_3.cpp)]
5858

59-
At least one argument to the concatenation operators (+ or +=) must be a `CString` object, but you can use a constant character string (for example, `"big"`) or a `char` (for example, 'x') for the other argument.
59+
At least one argument to the concatenation operators (+ or +=) must be a `CString` object, but you can use a constant character string (for example, `"big"`) or a **char** (for example, 'x') for the other argument.
6060

6161
## <a name="_core_comparing_cstring_objects"></a> Comparing CString Objects
62-
The `Compare` method and the == operator for `CString` are equivalent. `Compare`, `operator==`, and `CompareNoCase` are MBCS and Unicode aware; `CompareNoCase` is also case-insensitive. The `Collate` method of `CString` is locale-sensitive and is often slower than `Compare`. Use `Collate` only where you must abide by the sorting rules as specified by the current locale.
62+
The `Compare` method and the == operator for `CString` are equivalent. `Compare`, **operator==**, and `CompareNoCase` are MBCS and Unicode aware; `CompareNoCase` is also case-insensitive. The `Collate` method of `CString` is locale-sensitive and is often slower than `Compare`. Use `Collate` only where you must abide by the sorting rules as specified by the current locale.
6363

6464
The following table shows the available [CString](../atl-mfc-shared/reference/cstringt-class.md) comparison functions and their equivalent Unicode/MBCS-portable functions in the C run-time library.
6565

docs/atl-mfc-shared/cfixedstringt-example-of-a-custom-string-manager.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,44 @@ ms.author: "mblome"
1212
ms.workload: ["cplusplus"]
1313
---
1414
# CFixedStringT: Example of a Custom String Manager
15-
The ATL library implements one example of a custom string manager used by class [CFixedStringT](../atl-mfc-shared/reference/cfixedstringt-class.md), called **CFixedStringMgr**. `CFixedStringT` is derived from [CStringT](../atl-mfc-shared/reference/cstringt-class.md) and implements a string that allocates its character data as part of the `CFixedStringT` object itself as long as the string is less than the length specified by the **t_nChars** template parameter of `CFixedStringT`. With this approach, the string does not need the heap at all, unless the length of the string grows beyond the size of the fixed buffer. Because `CFixedStringT` does not always use a heap to allocate its string data, it cannot use **CAtlStringMgr** as its string manager. It uses a custom string manager (**CFixedStringMgr**), implementing the [IAtlStringMgr](../atl-mfc-shared/reference/iatlstringmgr-class.md) interface. This interface is discussed in [Implementation of a Custom String Manager (Advanced Method)](../atl-mfc-shared/implementation-of-a-custom-string-manager-advanced-method.md).
15+
The ATL library implements one example of a custom string manager used by class [CFixedStringT](../atl-mfc-shared/reference/cfixedstringt-class.md), called **CFixedStringMgr**. `CFixedStringT` is derived from [CStringT](../atl-mfc-shared/reference/cstringt-class.md) and implements a string that allocates its character data as part of the `CFixedStringT` object itself as long as the string is less than the length specified by the `t_nChars` template parameter of `CFixedStringT`. With this approach, the string does not need the heap at all, unless the length of the string grows beyond the size of the fixed buffer. Because `CFixedStringT` does not always use a heap to allocate its string data, it cannot use `CAtlStringMgr` as its string manager. It uses a custom string manager (`CFixedStringMgr`), implementing the [IAtlStringMgr](../atl-mfc-shared/reference/iatlstringmgr-class.md) interface. This interface is discussed in [Implementation of a Custom String Manager (Advanced Method)](../atl-mfc-shared/implementation-of-a-custom-string-manager-advanced-method.md).
1616

17-
The constructor for **CFixedStringMgr** takes three parameters:
17+
The constructor for `CFixedStringMgr` takes three parameters:
1818

19-
- **pData:** A pointer to the fixed `CStringData` structure to be used.
19+
- *pData:* A pointer to the fixed `CStringData` structure to be used.
2020

21-
- **nChars:** The maximum number of characters the `CStringData` structure can hold.
21+
- *nChars:* The maximum number of characters the `CStringData` structure can hold.
2222

23-
- **pMgr:** A pointer to the `IAtlStringMgr` interface of a "backup string manager."
23+
- *pMgr:* A pointer to the `IAtlStringMgr` interface of a "backup string manager."
2424

25-
The constructor stores the values of `pData` and **pMgr** in their respective member variables (`m_pData` and **m_pMgr**). It then sets the length of the buffer to zero, the available length equal to the maximum size of the fixed buffer, and the reference count to -1. The reference count value indicates the buffer is locked and to use this instance of **CFixedStringMgr** as the string manager.
25+
The constructor stores the values of *pData* and *pMgr* in their respective member variables (`m_pData` and `m_pMgr`). It then sets the length of the buffer to zero, the available length equal to the maximum size of the fixed buffer, and the reference count to -1. The reference count value indicates the buffer is locked and to use this instance of `CFixedStringMgr` as the string manager.
2626

2727
Marking the buffer as locked prevents other `CStringT` instances from holding a shared reference to the buffer. If other `CStringT` instances were allowed to share the buffer it would be possible for the buffer contained by `CFixedStringT` to be deleted while other strings were still using the buffer.
2828

29-
**CFixedStringMgr** is a full implementation of the `IAtlStringMgr` interface. The implementation of each method is discussed separately.
29+
`CFixedStringMgr` is a full implementation of the `IAtlStringMgr` interface. The implementation of each method is discussed separately.
3030

3131
## Implementation of CFixedStringMgr::Allocate
32-
The implementation of **CFixedStringMgr::Allocate** first checks to see if the requested size of the string is less than or equal to the size of the fixed buffer (stored in the `m_pData` member). If the fixed buffer is large enough, **CFixedStringMgr** locks the fixed buffer with a length of zero. As long as the string length does not grow beyond the size of the fixed buffer, `CStringT` will not have to reallocate the buffer.
32+
The implementation of `CFixedStringMgr::Allocate` first checks to see if the requested size of the string is less than or equal to the size of the fixed buffer (stored in the `m_pData` member). If the fixed buffer is large enough, `CFixedStringMgr` locks the fixed buffer with a length of zero. As long as the string length does not grow beyond the size of the fixed buffer, `CStringT` will not have to reallocate the buffer.
3333

34-
If the requested size of the string is greater than the fixed buffer **CFixedStringMgr** forwards the request to the backup string manager. The backup string manager is presumed to allocate the buffer from the heap. However, before returning this buffer **CFixedStringMgr** locks the buffer and replaces the buffer's string manager pointer with a pointer to the **CFixedStringMgr** object. This ensures that attempts to reallocate or free the buffer by `CStringT` will call into **CFixedStringMgr**.
34+
If the requested size of the string is greater than the fixed buffer `CFixedStringMgr` forwards the request to the backup string manager. The backup string manager is presumed to allocate the buffer from the heap. However, before returning this buffer `CFixedStringMgr` locks the buffer and replaces the buffer's string manager pointer with a pointer to the `CFixedStringMgr` object. This ensures that attempts to reallocate or free the buffer by `CStringT` will call into `CFixedStringMgr`.
3535

3636
## Implementation of CFixedStringMgr::ReAllocate
37-
The implementation of **CFixedStringMgr::ReAllocate** is very similar to its implementation of **Allocate**.
37+
The implementation of `CFixedStringMgr::ReAllocate` is very similar to its implementation of `Allocate`.
3838

3939
If the buffer being reallocated is the fixed buffer and the requested buffer size is smaller than the fixed buffer, no allocation is done. However, if the buffer being reallocated is not the fixed buffer, it must be a buffer allocated with the backup manager. In this case the backup manager is used to reallocate the buffer.
4040

41-
If the buffer being reallocated is the fixed buffer and the new buffer size is too large to fit within the fixed buffer, **CFixedStringMgr** allocates a new buffer using the backup manager. The contents of the fixed buffer are then copied into the new buffer.
41+
If the buffer being reallocated is the fixed buffer and the new buffer size is too large to fit within the fixed buffer, `CFixedStringMgr` allocates a new buffer using the backup manager. The contents of the fixed buffer are then copied into the new buffer.
4242

4343
## Implementation of CFixedStringMgr::Free
44-
The implementation of **CFixedStringMgr::Free** follows the same pattern as **Allocate** and `ReAllocate`. If the buffer being freed is the fixed buffer, the method sets it to a zero-length locked buffer. If the buffer being freed was allocated with the backup manager, **CFixedStringMgr** uses the backup manager to free it.
44+
The implementation of `CFixedStringMgr::Free` follows the same pattern as `Allocate` and `ReAllocate`. If the buffer being freed is the fixed buffer, the method sets it to a zero-length locked buffer. If the buffer being freed was allocated with the backup manager, `CFixedStringMgr` uses the backup manager to free it.
4545

4646
## Implementation of CFixedStringMgr::Clone
47-
The implementation of **CFixedStringMgr::Clone** always returns a pointer to the backup manager rather than the **CFixedStringMgr** itself. This happens because every instance of **CFixedStringMgr** can only be associated with a single instance of `CStringT`. Any other instances of `CStringT` trying to clone the manager should get the backup manager instead. This is because the backup manager supports being shared.
47+
The implementation of `CFixedStringMgr::Clone` always returns a pointer to the backup manager rather than the `CFixedStringMgr` itself. This happens because every instance of `CFixedStringMgr` can only be associated with a single instance of `CStringT`. Any other instances of `CStringT` trying to clone the manager should get the backup manager instead. This is because the backup manager supports being shared.
4848

4949
## Implementation of CFixedStringMgr::GetNilString
50-
The implementation of **CFixedStringMgr::GetNilString** returns the fixed buffer. Because of the one-on-one correspondence of **CFixedStringMgr** and `CStringT`, a given instance of `CStringT` never uses more than one buffer at a time. Therefore, a nil string and a real string buffer are never needed at the same time.
50+
The implementation of `CFixedStringMgr::GetNilString` returns the fixed buffer. Because of the one-on-one correspondence of `CFixedStringMgr` and `CStringT`, a given instance of `CStringT` never uses more than one buffer at a time. Therefore, a nil string and a real string buffer are never needed at the same time.
5151

52-
Whenever the fixed buffer is not in use, **CFixedStringMgr** ensures that it is initialized with a zero length. This allows it to be used as the nil string. As an added bonus, the `nAllocLength` member of the fixed buffer is always set to the full size of the fixed buffer. This means that `CStringT` can grow the string without calling [IAtlStringMgr::Reallocate](../atl-mfc-shared/reference/iatlstringmgr-class.md#reallocate), even for the nil string.
52+
Whenever the fixed buffer is not in use, `CFixedStringMgr` ensures that it is initialized with a zero length. This allows it to be used as the nil string. As an added bonus, the `nAllocLength` member of the fixed buffer is always set to the full size of the fixed buffer. This means that `CStringT` can grow the string without calling [IAtlStringMgr::Reallocate](../atl-mfc-shared/reference/iatlstringmgr-class.md#reallocate), even for the nil string.
5353

5454
## Requirements
5555
**Header:** cstringt.h

0 commit comments

Comments
 (0)