Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/build/cmake-presets-json-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Options for a `remotePrebuildEvent` and `remotePostbuildEvent` have been depreca

Encode pre-build, pre-link, and post-build events in your CMakeLists.txt using [add_custom_command](https://cmake.org/cmake/help/latest/command/add_custom_command.html#build-events). This will ensure the same behavior when building with Visual Studio and from the command line.

If you need behavior that is specific to Visual Studio, you can add a custom remote task in` tasks.vs.json`. To get started, right-click on your root `CMakeLists.txt` in the **Solution Explorer** from **Folder View** and select **Configure Tasks**. You can then [add a new remote task](https://docs.microsoft.com/cpp/build/tasks-vs-json-schema-reference-cpp#remote-properties) to your `tasks.vs.json` file.
If you need behavior that is specific to Visual Studio, you can add a custom remote task in` tasks.vs.json`. To get started, right-click on your root `CMakeLists.txt` in the **Solution Explorer** from **Folder View** and select **Configure Tasks**. You can then [add a new remote task](/cpp/build/tasks-vs-json-schema-reference-cpp#remote-properties) to your `tasks.vs.json` file.

The following remote task creates a directory called test on the remote Linux system:

Expand Down
8 changes: 4 additions & 4 deletions docs/build/cmake-presets-vs.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ If you've identified a problem, the best way to report it is by clicking the **S

## Logging for remote connections

You can enable logging for remote connections if you're having trouble connecting or copying files to a remote system. For more information, see [logging for remote connections](https://docs.microsoft.com/cpp/linux/connect-to-your-remote-linux-computer#logging-for-remote-connections).
You can enable logging for remote connections if you're having trouble connecting or copying files to a remote system. For more information, see [logging for remote connections](/cpp/linux/connect-to-your-remote-linux-computer#logging-for-remote-connections).

## Enable AddressSanitizer for Windows and Linux

Expand All @@ -399,7 +399,7 @@ if(ASAN_ENABLED)
endif()
```

`<additional-options>` are other compilation flags like `"-fno-omit-frame-pointer"`. For more information about AddressSanitizer for Linux, see [Using AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer#using-addresssanitizer). For more information about using AddressSanitizer with MSVC, see [Use the AddressSanitizer from a Developer Command Prompt](https://docs.microsoft.com/cpp/sanitizers/asan#command-prompt).
`<additional-options>` are other compilation flags like `"-fno-omit-frame-pointer"`. For more information about AddressSanitizer for Linux, see [Using AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer#using-addresssanitizer). For more information about using AddressSanitizer with MSVC, see [Use the AddressSanitizer from a Developer Command Prompt](/cpp/sanitizers/asan#command-prompt).

Pass runtime flags to AddressSanitizer by using the `ASAN_OPTIONS` field in `launch.vs.json`. `ASAN_OPTIONS` defaults to `detect_leaks=0` when no other runtime options are specified because LeakSanitizer isn't supported in Visual Studio.

Expand All @@ -409,7 +409,7 @@ You can use the same `CMakePresets.json` and `CMakeUserPresets.json` files to in

### Sourcing the environment when building with command-line generators on Windows

It's up to the user to configure the environment before CMake is invoked when building with a command-line generator. If you're building with Ninja and the Visual C++ toolset on Windows, then set the environment before CMake is called to generate the build system. You can do it by calling `vcvarsall.bat` with the `architecture` argument. `architecture` specifies the host and target architecture to use. For more information, see [`vcvarsall` syntax](https://docs.microsoft.com/cpp/build/building-on-the-command-line#vcvarsall-syntax). If you build on Linux or on Windows with a Visual Studio Generator, then you don't need to take this step.
It's up to the user to configure the environment before CMake is invoked when building with a command-line generator. If you're building with Ninja and the Visual C++ toolset on Windows, then set the environment before CMake is called to generate the build system. You can do it by calling `vcvarsall.bat` with the `architecture` argument. `architecture` specifies the host and target architecture to use. For more information, see [`vcvarsall` syntax](/cpp/build/building-on-the-command-line#vcvarsall-syntax). If you build on Linux or on Windows with a Visual Studio Generator, then you don't need to take this step.

It's the same step that Visual Studio takes for you when CMake is invoked by the IDE. Visual Studio parses the active Configure Preset for the host and target architecture specified by `toolset` and `architecture` and then sources the specified environment from `vcvarsall.bat`. When you build from the Windows command line with Ninja, you'll need to take this step yourself.

Expand Down Expand Up @@ -439,4 +439,4 @@ Learn more about configuring and debugging CMake projects in Visual Studio:
> [Customize CMake build settings](customize-cmake-settings.md)<br/><br/>
> [Configure CMake debugging sessions](configure-cmake-debugging-sessions.md)<br/><br/>
> [CMake predefined configuration reference](cmake-predefined-configuration-reference.md)
>
>
18 changes: 10 additions & 8 deletions docs/cpp/char-wchar-t-char16-t-char32-t.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
description: "Learn more about: char, wchar_t, char16_t, char32_t"
title: "char, wchar_t, char16_t, char32_t"
ms.date: "02/14/2018"
description: "Learn more about: char, wchar_t, char8_t, char16_t, char32_t"
title: "char, wchar_t, char8_t, char16_t, char32_t"
ms.date: 04/23/2021
ms.assetid: 6b33e9f5-455b-4e49-8f12-a150cbfe2e5b
---
# char, wchar_t, char16_t, char32_t
# char, wchar_t, char8_t, char16_t, char32_t

The types **`char`**, **`wchar_t`**, **`char16_t`** and **`char32_t`** are built-in types that represent alphanumeric characters as well as non-alphanumeric glyphs and non-printing characters.
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.

## Syntax

Expand All @@ -19,10 +19,12 @@ char32_t ch4{ U'a' };

## Remarks

The **`char`** type was the original character type in C and C++. The type **`unsigned char`** is often used to represent a *byte*, which is not a built-in type in 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. Strings of **`char`** type are referred to as *narrow* strings, even when used to encode multi-byte characters. In the Microsoft compiler, **`char`** is an 8-bit type.
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.

The type **`unsigned char`** is often used to represent a *byte*, which isn't a built-in type in C++.

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.

The **`char16_t`** and **`char32_t`** types represent 16-bit and 32-bit wide characters, respectively. 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.
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++latest`](../build/reference/std-specify-language-standard-version.md) 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.

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::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.
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.
2 changes: 1 addition & 1 deletion docs/cpp/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
href: ../cpp/false-cpp.md
- name: true
href: ../cpp/true-cpp.md
- name: char, wchar_t, char16_t, char32_t
- name: char, wchar_t, char8_t, char16_t, char32_t
href: ../cpp/char-wchar-t-char16-t-char32-t.md
- name: __int8, __int16, __int32, __int64
href: ../cpp/int8-int16-int32-int64.md
Expand Down