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
The types **`char`**, **`wchar_t`**, **`char8_t`**, **`char16_t`**, and **`char32_t`** are built-in types that represent alphanumeric characters, non-alphanumeric glyphs, and non-printing characters.
8
+
The types **`char`**, **`wchar_t`**, **`char8_t`**, **`char16_t`**, and **`char32_t`** are built-in types that represent alphanumeric characters, nonalphanumeric glyphs, and nonprinting characters.
10
9
11
10
## Syntax
12
11
@@ -19,12 +18,14 @@ char32_t ch4{ U'a' };
19
18
20
19
## Remarks
21
20
22
-
The **`char`** type was the original character type in C and C++. The **`char`** type can be used to store characters from the ASCII character set or any of the ISO-8859 character sets, and individual bytes of multi-byte characters such as Shift-JIS or the UTF-8 encoding of the Unicode character set. In the Microsoft compiler, **`char`** is an 8-bit type. It's a distinct type from both **`signed char`** and **`unsigned char`**. By default, variables of type **`char`** get promoted to **`int`** as if from type **`signed char`** unless the [`/J`](../build/reference/j-default-char-type-is-unsigned.md) compiler option is used. Under **`/J`**, they're treated as type **`unsigned char`** and get promoted to **`int`** without sign extension.
21
+
The **`char`** type was the original character type in C and C++. The **`char`** type stores characters from the ASCII character set or any of the ISO-8859 character sets, and individual bytes of multi-byte characters such as Shift-JIS or the UTF-8 encoding of the Unicode character set. In the Microsoft compiler, **`char`** is an 8-bit type. It's a distinct type from both **`signed char`** and **`unsigned char`**. By default, variables of type **`char`** get promoted to **`int`** as if from type **`signed char`** unless the [`/J`](../build/reference/j-default-char-type-is-unsigned.md) compiler option is used. Under **`/J`**, they're treated as type **`unsigned char`** and get promoted to **`int`** without sign extension.
23
22
24
23
The type **`unsigned char`** is often used to represent a *byte*, which isn't a built-in type in C++.
25
24
26
25
The **`wchar_t`** type is an implementation-defined wide character type. In the Microsoft compiler, it represents a 16-bit wide character used to store Unicode encoded as UTF-16LE, the native character type on Windows operating systems. The wide character versions of the Universal C Runtime (UCRT) library functions use **`wchar_t`** and its pointer and array types as parameters and return values, as do the wide character versions of the native Windows API.
27
26
28
27
The **`char8_t`**, **`char16_t`**, and **`char32_t`** types represent 8-bit, 16-bit, and 32-bit wide characters, respectively. (**`char8_t`** is new in C++20 and requires the [`/std:c++20`](../build/reference/std-specify-language-standard-version.md) or **`/std:c++latest`** compiler option.) Unicode encoded as UTF-8 can be stored in the **`char8_t`** type. Strings of **`char8_t`** and **`char`** type are referred to as *narrow* strings, even when used to encode Unicode or multi-byte characters. Unicode encoded as UTF-16 can be stored in the **`char16_t`** type, and Unicode encoded as UTF-32 can be stored in the **`char32_t`** type. Strings of these types and **`wchar_t`** are all referred to as *wide* strings, though the term often refers specifically to strings of **`wchar_t`** type.
29
28
30
-
In the C++ standard library, the `basic_string` type is specialized for both narrow and wide strings. Use `std::string` when the characters are of type **`char`**, `std::u8string` when the characters are of type **`char8_t`**, `std::u16string` when the characters are of type **`char16_t`**, `std::u32string` when the characters are of type **`char32_t`**, and `std::wstring` when the characters are of type **`wchar_t`**. Other types that represent text, including `std::stringstream` and `std::cout` have specializations for narrow and wide strings.
29
+
In the C++ standard library, the [`basic_string`](/cpp/standard-library/basic-string-class) type is specialized for both narrow and wide strings. Use `std::string` when the characters are of type **`char`**, `std::u8string` when the characters are of type **`char8_t`**, `std::u16string` when the characters are of type **`char16_t`**, `std::u32string` when the characters are of type **`char32_t`**, and `std::wstring` when the characters are of type **`wchar_t`**.
30
+
31
+
Other types that represent text, including [`std::stringstream`](/cpp/standard-library/sstream-typedefs/#stringstream) and [`std::cout`](/cpp/standard-library/iostream#cout) have specializations for narrow and wide strings.
|[Compiler error C3351](compiler-error-c3351.md)| '*function*': if you pass a NULL object instance to a delegate constructor you must also pass the address of a static member function |
|[Compiler error C3351](compiler-error-c3351.md)| '*function*': if you pass a NULL object instance to a delegate constructor you must also pass the address of a static member function |
71
70
|[Compiler error C3352](compiler-error-c3352.md)| '*function*': the specified function does not match the delegate type '*type*' |
72
71
|[Compiler error C3353](compiler-error-c3353.md)| '*identifier*': a delegate can only be created from a global function or a member function of a managed/WinRT type |
73
72
|[Compiler error C3354](compiler-error-c3354.md)| '*identifier*': the function used to create a delegate cannot have return type '*type*' |
@@ -117,6 +116,8 @@ The articles in this section of the documentation explain a subset of the error
117
116
|[Compiler error C3398](compiler-error-c3398.md)| '*operator*': cannot convert from '*type*' to '*type*'. Source expression must be a function symbol |
118
117
|[Compiler error C3399](compiler-error-c3399.md)| '*type*': cannot provide arguments when creating an instance of a generic parameter |
119
118
119
+
1-No longer emitted in Visual Studio 2022 version 17.11
120
+
120
121
## See also
121
122
122
123
[C/C++ Compiler and build tools errors and warnings](../compiler-errors-1/c-cpp-build-errors.md)\
0 commit comments