Skip to content

Commit ae2857d

Browse files
authored
Merge pull request #3577 from MicrosoftDocs/master
5/17/2021 AM Publish
2 parents 3abc4ab + 9e5770e commit ae2857d

File tree

78 files changed

+3664
-3664
lines changed

Some content is hidden

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

78 files changed

+3664
-3664
lines changed

docs/atl-mfc-shared/allocating-and-releasing-memory-for-a-bstr.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ f1_keywords: ["bstr"]
66
helpviewer_keywords: ["BSTRs, memory allocation", "memory deallocation, string memory", "memory [C++], releasing", "memory allocation, BSTRs", "memory deallocation, BSTR memory", "strings [C++], releasing"]
77
ms.assetid: 98041e29-3442-4a02-b425-7a4a13e9cc84
88
---
9-
# Allocating and Releasing Memory for a BSTR
9+
# Allocating and Releasing Memory for a `BSTR`
1010

1111
When you create `BSTR`s and pass them between COM objects, you must take care in treating the memory they use in order to avoid memory leaks. When a `BSTR` stays within an interface, you must free its memory when you are done with it. However, when a `BSTR` passes out of an interface, the receiving object takes responsibility for its memory management.
1212

@@ -31,6 +31,6 @@ In general, the rules for allocating and releasing memory allocated for `BSTR`s
3131
## See also
3232

3333
[Strings (ATL/MFC)](../atl-mfc-shared/strings-atl-mfc.md)<br/>
34-
[CStringT::AllocSysString](../atl-mfc-shared/reference/cstringt-class.md#allocsysstring)<br/>
35-
[SysAllocString](/windows/win32/api/oleauto/nf-oleauto-sysallocstring)<br/>
36-
[SysFreeString](/windows/win32/api/oleauto/nf-oleauto-sysfreestring)
34+
[`CStringT::AllocSysString`](../atl-mfc-shared/reference/cstringt-class.md#allocsysstring)<br/>
35+
[`SysAllocString`](/windows/win32/api/oleauto/nf-oleauto-sysallocstring)<br/>
36+
[`SysFreeString`](/windows/win32/api/oleauto/nf-oleauto-sysfreestring)

docs/atl-mfc-shared/unicode-and-multibyte-character-set-mbcs-support.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Microsoft has recommended the MFC Unicode libraries for all new development, and
1616

1717
## MFC Support for Unicode Strings
1818

19-
The entire MFC class library is conditionally enabled for Unicode characters and strings stored in wide characters as UTF-16. In particular, class [CString](../atl-mfc-shared/reference/cstringt-class.md) is Unicode-enabled.
19+
The entire MFC class library is conditionally enabled for Unicode characters and strings stored in wide characters as UTF-16. In particular, class [`CString`](../atl-mfc-shared/reference/cstringt-class.md) is Unicode-enabled.
2020

2121
These library, debugger, and DLL files are used to support Unicode in MFC:
2222

@@ -51,23 +51,23 @@ These library, debugger, and DLL files are used to support Unicode in MFC:
5151

5252
(*version* represents the version number of the file; for example, '140' means version 14.0.)
5353

54-
`CString` is based on the TCHAR data type. If the symbol _UNICODE is defined for a build of your program, TCHAR is defined as type **`wchar_t`**, a 16-bit character encoding type. Otherwise, TCHAR is defined as **`char`**, the normal 8-bit character encoding. Therefore, under Unicode, a `CString` is composed of 16-bit characters. Without Unicode, it is composed of characters of type **`char`**.
54+
`CString` is based on the `TCHAR` data type. If the symbol `_UNICODE` is defined for a build of your program, `TCHAR` is defined as type **`wchar_t`**, a 16-bit character encoding type. Otherwise, `TCHAR` is defined as **`char`**, the normal 8-bit character encoding. Therefore, under Unicode, a `CString` is composed of 16-bit characters. Without Unicode, it is composed of characters of type **`char`**.
5555

5656
To complete Unicode programming of your application, you must also:
5757

58-
- Use the _T macro to conditionally code literal strings to be portable to Unicode.
58+
- Use the `_T` macro to conditionally code literal strings to be portable to Unicode.
5959

6060
- When you pass strings, pay attention to whether function arguments require a length in characters or a length in bytes. The difference is important if you are using Unicode strings.
6161

6262
- Use portable versions of the C run-time string-handling functions.
6363

6464
- Use the following data types for characters and character pointers:
6565

66-
- Use TCHAR where you would use **`char`**.
66+
- Use `TCHAR` where you would use **`char`**.
6767

68-
- Use LPTSTR where you would use **`char`**<strong>\*</strong>.
68+
- Use `LPTSTR` where you would use **`char`**<strong>\*</strong>.
6969

70-
- Use LPCTSTR where you would use **`const char`**<strong>\*</strong>. `CString` provides the operator LPCTSTR to convert between `CString` and LPCTSTR.
70+
- Use `LPCTSTR` where you would use **`const char`**<strong>\*</strong>. `CString` provides the operator `LPCTSTR` to convert between `CString` and `LPCTSTR`.
7171

7272
`CString` also supplies Unicode-aware constructors, assignment operators, and comparison operators.
7373

@@ -79,27 +79,27 @@ The class library is also enabled for multibyte character sets, but only for dou
7979

8080
In a multibyte character set, a character can be one or two bytes wide. If it is two bytes wide, its first byte is a special "lead byte" that is chosen from a particular range, depending on which code page is in use. Taken together, the lead and "trail bytes" specify a unique character encoding.
8181

82-
If the symbol _MBCS is defined for a build of your program, type TCHAR, on which `CString` is based, maps to **`char`**. It is up to you to determine which bytes in a `CString` are lead bytes and which are trail bytes. The C run-time library supplies functions to help you determine this.
82+
If the symbol `_MBCS` is defined for a build of your program, type `TCHAR`, on which `CString` is based, maps to **`char`**. It is up to you to determine which bytes in a `CString` are lead bytes and which are trail bytes. The C run-time library supplies functions to help you determine this.
8383

8484
Under DBCS, a given string can contain all single-byte ANSI characters, all double-byte characters, or a combination of the two. These possibilities require special care in parsing strings. This includes `CString` objects.
8585

8686
> [!NOTE]
8787
> Unicode string serialization in MFC can read both Unicode and MBCS strings regardless of which version of the application that you are running. Your data files are portable between Unicode and MBCS versions of your program.
8888
89-
`CString` member functions use special "generic text" versions of the C run-time functions they call, or they use Unicode-aware functions. Therefore, for example, if a `CString` function would typically call `strcmp`, it calls the corresponding generic-text function `_tcscmp` instead. Depending on how the symbols _MBCS and _UNICODE are defined, `_tcscmp` maps as follows:
89+
`CString` member functions use special "generic text" versions of the C run-time functions they call, or they use Unicode-aware functions. Therefore, for example, if a `CString` function would typically call `strcmp`, it calls the corresponding generic-text function `_tcscmp` instead. Depending on how the symbols `_MBCS` and `_UNICODE` are defined, `_tcscmp` maps as follows:
9090

9191
|Symbols|Function|
9292
|-|-|
93-
|_MBCS defined|`_mbscmp`|
94-
|_UNICODE defined|`wcscmp`|
93+
|`_MBCS` defined|`_mbscmp`|
94+
|`_UNICODE` defined|`wcscmp`|
9595
|Neither symbol defined|`strcmp`|
9696

9797
> [!NOTE]
98-
> The symbols _MBCS and _UNICODE are mutually exclusive.
98+
> The symbols `_MBCS` and `_UNICODE` are mutually exclusive.
9999
100100
Generic-text function mappings for all of the run-time string-handling routines are discussed in [C Run-Time Library Reference](../c-runtime-library/c-run-time-library-reference.md). For a list, see [Internationalization](../c-runtime-library/internationalization.md).
101101

102-
Similarly, `CString` methods are implemented by using generic data type mappings. To enable both MBCS and Unicode, MFC uses TCHAR for **`char`** or **`wchar_t`**, LPTSTR for **`char`**<strong>\*</strong> or `wchar_t*`, and LPCTSTR for **const char**<strong>\*</strong> or `const wchar_t*`. These ensure the correct mappings for either MBCS or Unicode.
102+
Similarly, `CString` methods are implemented by using generic data type mappings. To enable both MBCS and Unicode, MFC uses `TCHAR` for **`char`** or **`wchar_t`**, `LPTSTR` for **`char`**<strong>\*</strong> or `wchar_t*`, and `LPCTSTR` for **`const char`**<strong>\*</strong> or `const wchar_t*`. These ensure the correct mappings for either MBCS or Unicode.
103103

104104
## See also
105105

docs/c-runtime-library/country-region-strings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ The Microsoft C run-time library implementation also supports the following addi
4444

4545
[Locale Names, Languages, and Country/Region Strings](../c-runtime-library/locale-names-languages-and-country-region-strings.md)<br/>
4646
[Language Strings](../c-runtime-library/language-strings.md)<br/>
47-
[setlocale, _wsetlocale](../c-runtime-library/reference/setlocale-wsetlocale.md)<br/>
48-
[_create_locale, _wcreate_locale](../c-runtime-library/reference/create-locale-wcreate-locale.md)
47+
[`setlocale`, `_wsetlocale`](../c-runtime-library/reference/setlocale-wsetlocale.md)<br/>
48+
[`_create_locale`, `_wcreate_locale`](../c-runtime-library/reference/create-locale-wcreate-locale.md)

docs/c-runtime-library/errno-constants.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ helpviewer_keywords: ["E2BIG constant", "EACCES constant", "EAGAIN constant", "E
1717

1818
The **`errno`** constants are values assigned to [`errno`](../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) in the event of various error conditions.
1919

20-
ERRNO.H contains the definitions of the **`errno`** values. However, not all the definitions given in ERRNO.H are used in 32-bit Windows operating systems. Some of the values in ERRNO.H are present to maintain compatibility with the UNIX family of operating systems. The **`errno`** values in a 32-bit Windows operating system are a subset of the values for **`errno`** in UNIX systems.
20+
`ERRNO.H` contains the definitions of the **`errno`** values. However, not all the definitions given in `ERRNO.H` are used in 32-bit Windows operating systems. Some of the values in `ERRNO.H` are present to maintain compatibility with the UNIX family of operating systems. The **`errno`** values in a 32-bit Windows operating system are a subset of the values for **`errno`** in UNIX systems.
2121

2222
The **`errno`** value isn't necessarily the same as the actual error code returned by a system call from the Windows operating system. To access the actual operating system error code, use the [`_doserrno`](../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) variable, which contains this value.
2323

@@ -37,7 +37,7 @@ The following **`errno`** values are supported:
3737
| `EEXIST` | Files exists. An attempt has been made to create a file that already exists. For example, the `_O_CREAT` and `_O_EXCL` flags are specified in an `_open` call, but the named file already exists. | 17 |
3838
| `EFAULT` | Bad address. | 14 |
3939
| `EFBIG` | File too large. | 27 |
40-
| `EILSEQ` | Illegal sequence of bytes (for example, in an MBCS string). | 42 |
40+
| `EILSEQ` | Illegal sequence of bytes (for example, in an `MBCS` string). | 42 |
4141
| `EINTR` | Interrupted function. | 4 |
4242
| `EINVAL` | Invalid argument. An invalid value was given for one of the arguments to a function. For example, the value given for the origin when positioning a file pointer (by means of a call to `fseek`) is before the beginning of the file. | 22 |
4343
| `EIO` | I/O error. | 5 |

docs/c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ f1_keywords: ["_sys_errlist", "errno", "_sys_nerr", "_doserrno"]
1010
helpviewer_keywords: ["error codes, printing", "sys_errlist global variable", "doserrno global variable", "errno global variable", "_doserrno global variable", "_sys_errlist global variable", "_sys_nerr global variable", "sys_nerr global variable"]
1111
ms.assetid: adbec641-6d91-4e19-8398-9a34046bd369
1212
---
13-
# errno, _doserrno, _sys_errlist, and _sys_nerr
13+
# `errno`, `_doserrno`, `_sys_errlist`, and `_sys_nerr`
1414

1515
Global macros that hold error codes that are set during program execution, and string equivalents of the error codes for display.
1616

@@ -29,35 +29,35 @@ Both `errno` and `_doserrno` are set to 0 by the runtime during program startup.
2929

3030
On an error, `errno` is not necessarily set to the same value as the error code returned by a system call. For I/O operations, `_doserrno` stores the operating-system error-code equivalents of `errno` codes. For most non-I/O operations, the value of `_doserrno` is not set.
3131

32-
Each `errno` value is associated with an error message in `_sys_errlist` that can be printed by using one of the [perror](../c-runtime-library/reference/perror-wperror.md) functions, or stored in a string by using one of the [strerror](../c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md) or [strerror_s](../c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md) functions. The `perror` and `strerror` functions use the `_sys_errlist` array and `_sys_nerr`—the number of elements in `_sys_errlist`—to process error information. Direct access to `_sys_errlist` and `_sys_nerr` is deprecated for code-security reasons. We recommend that you use the more secure, functional versions instead of the global macros, as shown here:
32+
Each `errno` value is associated with an error message in `_sys_errlist` that can be printed by using one of the [`perror`](../c-runtime-library/reference/perror-wperror.md) functions, or stored in a string by using one of the [`strerror`](../c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md) or [`strerror_s`](../c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md) functions. The `perror` and `strerror` functions use the `_sys_errlist` array and `_sys_nerr`—the number of elements in `_sys_errlist`—to process error information. Direct access to `_sys_errlist` and `_sys_nerr` is deprecated for code-security reasons. We recommend that you use the more secure, functional versions instead of the global macros, as shown here:
3333

3434
|Global Macro|Functional Equivalents|
3535
|------------------|----------------------------|
36-
|`_doserrno`|[_get_doserrno](../c-runtime-library/reference/get-doserrno.md), [_set_doserrno](../c-runtime-library/reference/set-doserrno.md)|
37-
|`errno`|[_get_errno](../c-runtime-library/reference/get-errno.md), [_set_errno](../c-runtime-library/reference/set-errno.md)|
38-
|`_sys_errlist`, `_sys_nerr`|[strerror_s, _strerror_s, _wcserror_s, \__wcserror_s](../c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md)|
36+
|`_doserrno`|[`_get_doserrno`](../c-runtime-library/reference/get-doserrno.md), [`_set_doserrno`](../c-runtime-library/reference/set-doserrno.md)|
37+
|`errno`|[`_get_errno`](../c-runtime-library/reference/get-errno.md), [`_set_errno`](../c-runtime-library/reference/set-errno.md)|
38+
|`_sys_errlist`, `_sys_nerr`|[`strerror_s`, `_strerror_s`, `_wcserror_s`, `__wcserror_s`](../c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md)|
3939

40-
Library math routines set `errno` by calling [_matherr](../c-runtime-library/reference/matherr.md). To handle math errors differently, write your own routine according to the `_matherr` reference description and name it `_matherr`.
40+
Library math routines set `errno` by calling [`_matherr`](../c-runtime-library/reference/matherr.md). To handle math errors differently, write your own routine according to the `_matherr` reference description and name it `_matherr`.
4141

42-
All `errno` values are predefined constants in \<errno.h>, and are UNIX-compatible. Only `ERANGE`, `EILSEQ`, and `EDOM` are specified in the ISO C99 standard. For a complete list, see [errno Constants](../c-runtime-library/errno-constants.md).
42+
All `errno` values are predefined constants in `<errno.h>`, and are UNIX-compatible. Only `ERANGE`, `EILSEQ`, and `EDOM` are specified in the ISO C99 standard. For a complete list, see [errno Constants](../c-runtime-library/errno-constants.md).
4343

4444
## Requirements
4545

4646
|Global macro|Required header|Optional header|
4747
|------------------|---------------------|---------------------|
48-
|`errno`|\<errno.h> or \<stdlib.h>, \<cerrno> or \<cstdlib> (C++)||
49-
|`_doserrno`, `_sys_errlist`, `_sys_nerr`|\<stdlib.h>, \<cstdlib> (C++)|\<errno.h>, \<cerrno> (C++)|
48+
|`errno`|`<errno.h>` or `<stdlib.h>`, `<cerrno>` or `<cstdlib>` (C++)||
49+
|`_doserrno`, `_sys_errlist`, `_sys_nerr`|`<stdlib.h>`, `<cstdlib>` (C++)|`<errno.h>`, `<cerrno>` (C++)|
5050

5151
The `_doserrno`, `_sys_errlist`, and `_sys_nerr` macros are Microsoft extensions. For more compatibility information, see [Compatibility](../c-runtime-library/compatibility.md).
5252

5353
## See also
5454

5555
[Global Variables](../c-runtime-library/global-variables.md)<br/>
56-
[errno Constants](../c-runtime-library/errno-constants.md)<br/>
57-
[perror, _wperror](../c-runtime-library/reference/perror-wperror.md)<br/>
58-
[strerror, _strerror, _wcserror, \__wcserror](../c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md)<br/>
59-
[strerror_s, _strerror_s, _wcserror_s, \__wcserror_s](../c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md)<br/>
60-
[_get_doserrno](../c-runtime-library/reference/get-doserrno.md)<br/>
61-
[_set_doserrno](../c-runtime-library/reference/set-doserrno.md)<br/>
62-
[_get_errno](../c-runtime-library/reference/get-errno.md)<br/>
63-
[_set_errno](../c-runtime-library/reference/set-errno.md)
56+
[`errno` Constants](../c-runtime-library/errno-constants.md)<br/>
57+
[`perror`, `_wperror`](../c-runtime-library/reference/perror-wperror.md)<br/>
58+
[`strerror`, `_strerror`, `_wcserror`, `__wcserror`](../c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md)<br/>
59+
[`strerror_s`, `_strerror_s`, `_wcserror_s`, `__wcserror_s`](../c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md)<br/>
60+
[`_get_doserrno`](../c-runtime-library/reference/get-doserrno.md)<br/>
61+
[`_set_doserrno`](../c-runtime-library/reference/set-doserrno.md)<br/>
62+
[`_get_errno`](../c-runtime-library/reference/get-errno.md)<br/>
63+
[`_set_errno`](../c-runtime-library/reference/set-errno.md)

0 commit comments

Comments
 (0)