` value if you're using Visual Studio 2015, `v141` if you're using Visual Studio 2017, `v142` if you're using Visual Studio 2019 or `v143` if you're using Visual Studio 2022.)
```xml
Application
- v142
+ v143
```
@@ -162,10 +155,10 @@ An MSBuild project file is an XML file that contains a project root element (`
+
Debug
@@ -209,13 +202,9 @@ The application should display "Hello, from MSBuild!" in the console window.
MSBuild enables you to execute predefined build targets, apply user-defined properties, and use custom tools, events, and build steps. This section illustrates these tasks:
- Using MSBuild with build targets.
-
- Using MSBuild with build properties.
-
- Using MSBuild with the 64-bit compiler and tools.
-
- Using MSBuild with different toolsets.
-
- Adding MSBuild customizations.
### Using MSBuild with Build Targets
@@ -277,7 +266,10 @@ To rebuild your project with the Visual C++ 11.0 Windows XP toolset, enter this
MSBuild provides various ways to customize your build process. These articles show how to add custom build steps, tools, and events to your MSBuild project:
- [How to: Add a Custom Build Step to MSBuild Projects](how-to-add-a-custom-build-step-to-msbuild-projects.md)
-
- [How to: Add Custom Build Tools to MSBuild Projects](how-to-add-custom-build-tools-to-msbuild-projects.md)
-
- [How to: Use Build Events in MSBuild Projects](how-to-use-build-events-in-msbuild-projects.md)
+
+## See also
+
+- [vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
+- [Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
diff --git a/docs/build/working-with-project-properties.md b/docs/build/working-with-project-properties.md
index 9a6b533a19..7f6b508708 100644
--- a/docs/build/working-with-project-properties.md
+++ b/docs/build/working-with-project-properties.md
@@ -1,35 +1,39 @@
---
-title: "Set C++ compiler and build properties in Visual Studio"
+title: "Set C++ Compiler and Build Properties in Visual Studio"
description: "Use the Visual Studio IDE to change C++ compiler and linker options and other build settings."
-ms.date: "07/17/2019"
+ms.date: 03/19/2025
+ms.topic: concept-article
helpviewer_keywords: ["project properties [C++], modifying", "properties [C++]", "Visual C++ projects, properties", "projects [C++], properties"]
-ms.assetid: 9b0d6f8b-7d4e-4e61-aa75-7d14944816cd
---
# Set compiler and build properties
-In the IDE, all information that's needed to build a project is exposed as *properties*. This information includes the application name, extension (such as DLL, LIB, EXE), compiler options, linker options, debugger settings, custom build steps, and many other things. Typically, you use *property pages* to view and modify these properties. To access the property pages, choose **Project** > **_project-name_ Properties** from the main menu, or right-click on the project node in **Solution Explorer** and choose **Properties**.
+In the Visual Studio IDE, you can view and edit the properties needed to compile and build a project. This information includes the application name, extension (such as DLL, LIB, EXE), compiler options, linker options, debugger settings, and custom build steps.
+
+You can view and modify these properties by using *property pages*. To access the property pages, choose **Project** > **_project-name_ Properties** from the main menu, or right-click on the project node in **Solution Explorer** and choose **Properties**.
## Default properties
-When you create a project, the system assigns values for various properties. The defaults vary somewhat depending on the kind of project and what options you choose in the app wizard. For example, an ATL project has properties related to MIDL files, but these properties are absent in a basic console application. The default properties are shown in the General pane in the Property Pages:
+When you create a project, the system assigns values for various properties. The defaults vary somewhat depending on the kind of project and what options you choose in the app wizard. For example, an Active Template Library (ATL) project has properties related to Microsoft Interface Definition Language (MIDL) files, but these properties are absent in a basic console application. The default properties are shown in the Advanced pane in the **Property Pages** window:
-
+:::image type="content" source="media/visual-c---project-defaults.png" alt-text="Screenshot of the Visual Studio project properties dialog box with the Advanced pane selected. Properties such as Use of MFC, Character Set, and so on are highlighted." lightbox="media/visual-c---project-defaults.png":::
-## Applying properties to build configurations and target platforms
+## Apply properties to build configurations and target platforms
-Some properties, such as the application name, apply to all build variations and target platforms, whether it's a debug or release build. But most properties are configuration-dependent. To generate the correct code, the compiler has to know both the specific platform the program will run on and which specific compiler options to use. So when you set a property, it's important to pay attention to which configuration and platform the new value should apply to. Should it apply only to Debug Win32 builds, or should it also apply to Debug ARM64 and Debug x64? For example, the **Optimization** property, by default, is set to **Maximize Speed (/O2)** in a Release configuration, but it's disabled in the Debug configuration.
+Some properties, such as the application name, apply to all build variations and target platforms, whether it's a debug or release build. But most properties are configuration-dependent. To generate the correct code, the compiler has to know both the specific platform the program runs on and which specific compiler options to use. So when you set a property, it's important to pay attention to which configuration and platform the new value should apply to. Should it apply only to Debug Win32 builds, or should it also apply to Debug ARM64 and Debug x64? For example, the **Optimization** property, by default, is set to **Maximize Speed (/O2)** in a Release configuration, but is disabled in the Debug configuration.
-You can always see and change the configuration and platform a property value should apply to. The following illustration shows the property pages with the configuration and platform information controls at the top. When the **Optimization** property is set here, it will apply only to Debug Win32 builds, the currently active configuration, as shown by the red arrows.
+You can always see and change the configuration and platform a property value should apply to. The following illustration shows the property pages with the configuration and platform information controls at the top. When the **Optimization** property is set here, it only applies to Debug Win32 builds, the currently active configuration, as shown by the red arrows.
-
+:::image type="complex" source="media/visual-c---property-pages-showing-active-configuration.png" alt-text="Screenshot of the Visual Studio Property Pages dialog.":::
+The page is open to C/C++, Optimization. The Optimization setting is set to Disabled (/Od), which is called out. An arrow calls out the relationship between the Configuration setting in the project property page, which is set to Active(Debug), and the setting in the Solution configuration dropdown on the toolbar, which is set to Debug. Another arrow calls out the relationship between the Platform setting in the project property page, which is set to Active(Win32), and the setting in the Solutions platform dropdown on the toolbar, which is set to x86.
+:::image-end:::
The following illustration shows the same project property page, but the configuration has been changed to Release. Note the different value for the Optimization property. Also note that the active configuration is still Debug. You can set properties for any configuration here; it doesn't have to be the active one.
-
+:::image type="content" source="media/visual-c---property-pages-showing-release-config.png" alt-text="Screenshot of the Visual Studio project Property Pages dialog. The Configuration dropdown is called out and is set to Release. The optimization setting is set to Maximize Speed slash O2.":::
## Target platforms
-*Target platform* refers to the kind of device and operating system that the executable will run on. You can build a project for more than one platform. The available target platforms for C++ projects depend on the kind of project. They include but aren't limited to Win32, x64, ARM, ARM64, Android, and iOS. The **x86** target platform that you might see in **Configuration Manager** is identical to **Win32** in native C++ projects. Win32 means 32-bit Windows and **x64** means 64-bit Windows. For more information about these two platforms, see [Running 32-bit applications](/windows/win32/WinProg64/running-32-bit-applications).
+*Target platform* refers to the kind of device and operating system that the executable runs on. You can build a project for more than one platform. The available target platforms for C++ projects depend on the kind of project. They include but aren't limited to Win32, x64, ARM, ARM64, Android, and iOS. The **x86** target platform that you might see in **Configuration Manager** is identical to **Win32** in native C++ projects. Win32 means 32-bit Windows and **x64** means 64-bit Windows. For more information about these two platforms, see [Running 32-bit applications](/windows/win32/WinProg64/running-32-bit-applications).
The **Any CPU** target platform value that you might see in **Configuration Manager** has no effect on native C++ projects. It's only relevant for C++/CLI and other .NET project types. For more information, see [`/CLRIMAGETYPE` (Specify Type of CLR Image)](reference/clrimagetype-specify-type-of-clr-image.md).
@@ -42,37 +46,39 @@ For more information about setting properties for a Debug build, see:
## C++ compiler and linker options
-C++ compiler and linker options are located under the **C/C++** and **Linker** nodes in the left pane under **Configuration Properties**. These options translate directly to command-line options that will be passed to the compiler. To read documentation about a specific option, select the option in the center pane and press **F1**. Or, you can browse documentation for all the options at [MSVC compiler options](reference/compiler-options.md) and [MSVC linker options](reference/linker-options.md).
+C++ compiler and linker options are located under the **C/C++** and **Linker** nodes in the left pane under **Configuration Properties**. These options translate directly to command-line options that are passed to the compiler. To read documentation about a specific option, select the option in the center pane and press **F1**. Or, you can browse documentation for all the options at [MSVC compiler options](reference/compiler-options.md) and [MSVC linker options](reference/linker-options.md).
The **Property Pages** dialog box shows only the property pages that are relevant to the current project. For example, if the project doesn't have an *`.idl`* file, the MIDL property page isn't displayed. For more information about the settings on each property page, see [Property Pages (C++)](reference/property-pages-visual-cpp.md).
## Directory and path values
-MSBuild supports the use of compile-time constants for certain string values, such as include directories and paths, called *macros*. A macro can refer to a value that's defined by Visual Studio or the MSBuild system, or to a user-defined value. Macros look like `$(macro-name)` or `%(item-macro-name)`. They're exposed in the property pages, where you can refer to and modify them by using the [Property Editor](#property_editor). Use macros instead of hard-coded values such as directory paths. Macros make it easier to share property settings between machines and between versions of Visual Studio. And, you can better ensure that your project settings participate correctly in [property inheritance](project-property-inheritance.md).
+MSBuild supports the use of compile-time constants for certain string values, such as include directories and paths, called *macros*. A macro can refer to a value that's defined by Visual Studio or the MSBuild system, or to a user-defined value. Macros look like `$(macro-name)` or `%(item-macro-name)`. They're exposed in the property pages, where you can refer to and modify them by using the [Property Editor](#property_editor). Use macros instead of hard-coded values such as directory paths. Macros make it easier to share property settings between machines and between versions of Visual Studio. You can also better ensure that your project settings participate correctly in [property inheritance](project-property-inheritance.md).
The following illustration shows the property pages for a Visual Studio C++ project. In the left pane, the **VC++ Directories** *rule* is selected, and the right pane lists the properties that are associated with that rule. The property values are often macros, such as `$(VC_SourcePath)`:
-
+:::image type="complex" source="media/project_property_pages_vc.png" alt-text="Screenshot of the Visual Studio Property Pages dialog for rules for various directories.":::
+The VC plus plus Directories page is open, which has properties for the VC++ Directories rules. An example rule is Source directories, which is set to $(VC_SourcePath). There are rules for the include directories, library directories, executable directories, and so on.
+:::image-end:::
You can use the [Property Editor](#property_editor) to view the values of all available macros.
### Predefined macros
-- **Global macros**:\
+- **Global macros**\
Global macros apply to all items in a project configuration. A global macro has the syntax `$(name)`. An example of a global macro is `$(VCInstallDir)`, which stores the root directory of your Visual Studio installation. A global macro corresponds to a `PropertyGroup` in MSBuild.
- **Item macros**\
- Item macros have the syntax `%(name)`. For a file, an item macro applies only to that file—for example, you can use `%(AdditionalIncludeDirectories)` to specify include directories that apply only to a particular file. This kind of item macro corresponds to an `ItemGroup` metadata in MSBuild. When it's used in the context of a project configuration, an item macro applies to all files of a certain type. For example, the C/C++ **Preprocessor Definitions** configuration property can take a `%(PreprocessorDefinitions)` item macro that applies to all .cpp files in the project. This kind of item macro corresponds to an `ItemDefinitionGroup` metadata in MSBuild. For more information, see [Item Definitions](/visualstudio/msbuild/item-definitions).
+ Item macros have the syntax `%(name)`. For a file, an item macro applies only to that file. For example, you can use `%(AdditionalIncludeDirectories)` to specify include directories that apply only to a particular file. This kind of item macro corresponds to an `ItemGroup` metadata in MSBuild. When used in the context of a project configuration, an item macro applies to all files of a certain type. For example, the C/C++ **Preprocessor Definitions** configuration property can take a `%(PreprocessorDefinitions)` item macro that applies to all .cpp files in the project. This kind of item macro corresponds to an `ItemDefinitionGroup` metadata in MSBuild. For more information, see [Item definitions](/visualstudio/msbuild/item-definitions).
### User-defined macros
-You can create *user-defined macros* to use as variables in project builds. For example, you could create a user-defined macro that provides a value to a custom build step or a custom build tool. A user-defined macro is a name/value pair. In a project file, use the `$(name)` notation to access the value.
+You can create *user-defined macros* to use as variables in project builds. For example, you could create a user-defined macro that provides a value to a custom build step or a custom build tool. A user-defined macro is a name-value pair. In a project file, use the `$(name)` notation to access the value.
A user-defined macro is stored in a property sheet. If your project doesn't already contain a property sheet, you can create one by following the steps under [Share or reuse Visual Studio project settings](create-reusable-property-configurations.md).
#### To create a user-defined macro
-1. Open the **Property Manager** window. (On the menu bar, choose **View** > **Property Manager** or **View** > **Other Windows** > **Property Manager**.) Open the shortcut menu for a property sheet (its name ends in *`.user`*) and then choose **Properties**. The **Property Pages** dialog box for that property sheet opens.
+1. Open the **Property Manager** window. On the menu bar, select **View** > **Other Windows** > **Property Manager**. Open the shortcut menu for a property sheet (its name ends in *`.user`*) and then choose **Properties**. The **Property Pages** dialog box for that property sheet opens.
1. In the left pane of the dialog box, select **User Macros**. In the right pane, choose the **Add Macro** button to open the **Add User Macro** dialog box.
@@ -82,28 +88,29 @@ A user-defined macro is stored in a property sheet. If your project doesn't alre
You can use the Property Editor to modify certain string properties and select macros as values. To access the Property Editor, select a property on a property page and then choose the down arrow button on the right. If the drop-down list contains **\**, then you can choose it to display the Property Editor for that property.
-
+:::image type="complex" source="media/property_editor_dropdown.png" alt-text="Screenshot of the Visual Studio project properties page for VC plus plus Directories.":::
+The Property Editor for the Include Directories setting is open. It shows the evaluated value for the Include Directories, which is C:\Program Files(x86)\Microsoft Visual Studio 14.0\VC\Include. It shows the two inherited values: $(VC_IncludePath) and $(WindowsSDK_IncludePath). A checkbox for 'Inherit from parent or project defaults' is selected.
+:::image-end:::
In the Property Editor, you can choose the **Macros** button to view the available macros and their current values. The following illustration shows the Property Editor for the **Additional Include Directories** property after the **Macros** button was chosen. When the **Inherit from parent or project defaults** check box is selected and you add a new value, it's appended to any values that are currently being inherited. If you clear the check box, your new value replaces the inherited values. In most cases, leave the check box selected.
-
+:::image type="complex" source="media/propertyeditorvc.png" alt-text="Screenshot of the Property Editor dialog after selecting the Macros button.":::
+The property editor for Include Directories is open. The evaluated value is displayed along with the inherited values. A listbox contains various macros and their values, such as $(CharacterSet) which is set to Unicode.
+:::image-end:::
## Add an include directory to the set of default directories
-When you add an include directory to a project, it's important not to override all the default directories. The correct way to add a directory is to append the new path, for example "`C:\MyNewIncludeDir\`", and then to Append the **`$(IncludePath)`** macro to the property value.
+When you add an include directory to a project, it's important not to override all the default directories. The correct way to add a directory is to append the new path, for example `C:\MyNewIncludeDir\`, and then to append the `$(IncludePath)` macro to the property value.
## Quickly browse and search all properties
The **All Options** property page (under the **Configuration Properties** > **C/C++** node in the **Property Pages** dialog box) provides a quick way to browse and search the properties that are available in the current context. It has a special search box and a simple syntax to help you filter results:
-No prefix:\
-Search in property names only (case-insensitive substring).
+- No prefix: Search in property names only (case-insensitive substring).
-'`/`' or '`-`':\
-Search only in compiler switches (case-insensitive prefix)
+- '`/`' or '`-`': Search only in compiler switches (case-insensitive prefix).
-`v`:\
-Search only in values (case-insensitive substring).
+- `v`: Search only in values (case-insensitive substring).
## Set environment variables for a build
@@ -115,19 +122,14 @@ In the left pane of the project's **Property Pages** dialog box, expand **Config
In the right pane, modify the **Environment** or **Merge Environment** project settings and then choose the **OK** button.
-## In this section
-
-[Share or reuse Visual Studio project settings](create-reusable-property-configurations.md)\
-How to create a *`.props`* file with custom build settings that can be shared or reused.
-
-[Project property inheritance](project-property-inheritance.md)\
-Describes the order of evaluation for the *`.props`*, *`.targets`*, *`.vcxproj`* files, and environment variables in the build process.
+## Articles in this section
-[Modify properties and targets without changing the project file](modify-project-properties-without-changing-project-file.md)\
-How to create temporary build settings without having to modify a project file.
+- [Share or reuse Visual Studio project settings](create-reusable-property-configurations.md)
+- [Property inheritance in Visual Studio projects](project-property-inheritance.md)
+- [Modify C++ project properties and targets without changing the project file](modify-project-properties-without-changing-project-file.md)
## See also
-[Visual Studio Projects - C++](creating-and-managing-visual-cpp-projects.md)\
-[`.vcxproj` and `.props` file structure](reference/vcxproj-file-structure.md)\
-[Property page XML files](reference/property-page-xml-files.md)
+- [Visual Studio projects - C++](creating-and-managing-visual-cpp-projects.md)
+- [`.vcxproj` and `.props` file structure](reference/vcxproj-file-structure.md)
+- [Property Page XML rule files](reference/property-page-xml-files.md)
diff --git a/docs/build/x64-calling-convention.md b/docs/build/x64-calling-convention.md
index c03fee57e9..abb153a846 100644
--- a/docs/build/x64-calling-convention.md
+++ b/docs/build/x64-calling-convention.md
@@ -1,19 +1,22 @@
---
-title: "x64 calling convention"
-description: "Learn about the details of the default x64 calling convention."
-ms.date: 05/17/2022
+title: "x64 Calling Convention"
+description: "Learn about the default x64 calling convention that one function uses to make calls into another function."
+ms.date: 03/19/2025
+ms.topic: concept-article
---
# x64 calling convention
-This section describes the standard processes and conventions that one function (the caller) uses to make calls into another function (the callee) in x64 code.
+This article describes the standard processes and conventions that one function (the caller) uses to make calls into another function (the callee) in x64 code.
+
+For more information about the `__vectorcall` calling convention, see [__vectorcall](../cpp/vectorcall.md).
## Calling convention defaults
-The x64 Application Binary Interface (ABI) uses a four-register fast-call calling convention by default. Space is allocated on the call stack as a shadow store for callees to save those registers.
+The x64 Application Binary Interface (ABI) uses a four-register, fast-call calling convention by default. Space is allocated on the call stack as a shadow store for callees to save those registers.
There's a strict one-to-one correspondence between a function call's arguments and the registers used for those arguments. Any argument that doesn't fit in 8 bytes, or isn't 1, 2, 4, or 8 bytes, must be passed by reference. A single argument is never spread across multiple registers.
-The x87 register stack is unused. It may be used by the callee, but consider it volatile across function calls. All floating point operations are done using the 16 XMM registers.
+The x87 register stack is unused. It might be used by the callee, but consider it volatile across function calls. All floating point operations are done using the 16 XMM registers.
Integer arguments are passed in registers RCX, RDX, R8, and R9. Floating point arguments are passed in XMM0L, XMM1L, XMM2L, and XMM3L. 16-byte arguments are passed by reference. Parameter passing is described in detail in [Parameter passing](#parameter-passing). These registers, and RAX, R10, R11, XMM4, and XMM5, are considered *volatile*, or potentially changed by a callee on return. Register usage is documented in detail in [x64 register usage](x64-software-conventions.md#x64-register-usage) and [Caller/callee saved registers](#callercallee-saved-registers).
@@ -25,13 +28,13 @@ Most structures are aligned to their natural alignment. The primary exceptions a
## Unwindability
-Leaf functions are functions that don't change any non-volatile registers. A non-leaf function may change non-volatile RSP, for example, by calling a function. Or, it could change RSP by allocating additional stack space for local variables. To recover non-volatile registers when an exception is handled, non-leaf functions are annotated with static data. The data describes how to properly unwind the function at an arbitrary instruction. This data is stored as *pdata*, or procedure data, which in turn refers to *xdata*, the exception handling data. The xdata contains the unwinding information, and can point to additional pdata or an exception handler function.
+Leaf functions are functions that don't change any nonvolatile registers. A nonleaf function might change nonvolatile RSP, for example, by calling a function. Or, it could change RSP by allocating more stack space for local variables. To recover nonvolatile registers when an exception is handled, nonleaf functions are annotated with static data. The data describes how to properly unwind the function at an arbitrary instruction. This data is stored as *pdata*, or procedure data, which in turn refers to *xdata*, the exception handling data. The xdata contains the unwinding information, and can point to additional pdata or an exception handler function.
Prologs and epilogs are highly restricted so that they can be properly described in xdata. The stack pointer must remain 16-byte aligned in any region of code that isn't part of an epilog or prolog, except within leaf functions. Leaf functions can be unwound simply by simulating a return, so pdata and xdata aren't required. For details about the proper structure of function prologs and epilogs, see [x64 prolog and epilog](../build/prolog-and-epilog.md). For more information about exception handling, and the exception handling and unwinding of pdata and xdata, see [x64 exception handling](../build/exception-handling-x64.md).
## Parameter passing
-By default, the x64 calling convention passes the first four arguments to a function in registers. The registers used for these arguments depend on the position and type of the argument. Remaining arguments get pushed on the stack in right-to-left order.
+By default, the x64 calling convention passes the first four arguments to a function in registers. The registers used for these arguments depend on the position and type of the argument. Remaining arguments get pushed on the stack in right-to-left order. All arguments passed on the stack are 8-byte aligned.
Integer valued arguments in the leftmost four positions are passed in left-to-right order in RCX, RDX, R8, and R9, respectively. The fifth and higher arguments are passed on the stack as previously described. All integer arguments in registers are right-justified, so the callee can ignore the upper bits of the register and access only the portion of the register necessary.
@@ -99,15 +102,15 @@ func2() { // RCX = 2, RDX = XMM1 = 1.0, and R8 = 7
## Return values
-A scalar return value that can fit into 64 bits, including the **`__m64`** type, is returned through RAX. Non-scalar types including floats, doubles, and vector types such as [`__m128`](../cpp/m128.md), [`__m128i`](../cpp/m128i.md), [`__m128d`](../cpp/m128d.md) are returned in XMM0. The state of unused bits in the value returned in RAX or XMM0 is undefined.
+A scalar return value that can fit into 64 bits, including the `__m64` type, is returned through RAX. Nonscalar types including floats, doubles, and vector types such as [`__m128`](../cpp/m128.md), [`__m128i`](../cpp/m128i.md), [`__m128d`](../cpp/m128d.md) are returned in XMM0. The state of unused bits in the value returned in RAX or XMM0 is undefined.
-User-defined types can be returned by value from global functions and static member functions. To return a user-defined type by value in RAX, it must have a length of 1, 2, 4, 8, 16, 32, or 64 bits. It must also have no user-defined constructor, destructor, or copy assignment operator. It can have no private or protected non-static data members, and no non-static data members of reference type. It can't have base classes or virtual functions. And, it can only have data members that also meet these requirements. (This definition is essentially the same as a C++03 POD type. Because the definition has changed in the C++11 standard, we don't recommend using `std::is_pod` for this test.) Otherwise, the caller must allocate memory for the return value and pass a pointer to it as the first argument. The remaining arguments are then shifted one argument to the right. The same pointer must be returned by the callee in RAX.
+User-defined types can be returned by value from global functions and static member functions. To return a user-defined type by value in RAX, it must have a length of 1, 2, 4, 8, 16, 32, or 64 bits. It must also have no user-defined constructor, destructor, or copy assignment operator. It can have no private or protected nonstatic data members, and no nonstatic data members of reference type. It can't have base classes or virtual functions. And, it can only have data members that also meet these requirements. This definition is essentially the same as a C++03 POD type. Because the definition has changed in the C++11 standard, we don't recommend using `std::is_pod` for this test. Otherwise, the caller must allocate memory for the return value and pass a pointer to it as the first argument. The remaining arguments are then shifted one argument to the right. The same pointer must be returned by the callee in RAX.
These examples show how parameters and return values are passed for functions with the specified declarations:
### Example of return value 1 - 64-bit result
-```Output
+```cpp
__int64 func1(int a, float b, int c, int d, int e);
// Caller passes a in RCX, b in XMM1, c in R8, d in R9, e pushed on stack,
// callee returns __int64 result in RAX.
@@ -115,7 +118,7 @@ __int64 func1(int a, float b, int c, int d, int e);
### Example of return value 2 - 128-bit result
-```Output
+```cpp
__m128 func2(float a, double b, int c, __m64 d);
// Caller passes a in XMM0, b in XMM1, c in R8, d in R9,
// callee returns __m128 result in XMM0.
@@ -123,7 +126,7 @@ __m128 func2(float a, double b, int c, __m64 d);
### Example of return value 3 - user type result by pointer
-```Output
+```cpp
struct Struct1 {
int j, k, l; // Struct1 exceeds 64 bits.
};
@@ -135,7 +138,7 @@ Struct1 func3(int a, double b, int c, float d);
### Example of return value 4 - user type result by value
-```Output
+```cpp
struct Struct2 {
int j, k; // Struct2 fits in 64 bits, and meets requirements for return by value.
};
@@ -166,7 +169,7 @@ The x87 FPU control word register gets set using the following standard values a
| Register\[bits] | Setting |
|-|-|
-| FPCSR\[0:6] | Exception masks all 1's (all exceptions masked) |
+| FPCSR\[0:6] | Exception masks all 1s (all exceptions masked) |
| FPCSR\[7] | Reserved - 0 |
| FPCSR\[8:9] | Precision Control - 10B (double precision) |
| FPCSR\[10:11] | Rounding control - 0 (round to nearest) |
@@ -174,7 +177,7 @@ The x87 FPU control word register gets set using the following standard values a
A callee that modifies any of the fields within FPCSR must restore them before returning to its caller. Furthermore, a caller that has modified any of these fields must restore them to their standard values before invoking a callee, unless by agreement the callee expects the modified values.
-There are two exceptions to the rules about the non-volatility of the control flags:
+There are two exceptions to the rules about the nonvolatility of the control flags:
- In functions where the documented purpose of the given function is to modify the nonvolatile FPCSR flags.
@@ -189,13 +192,13 @@ The nonvolatile portion is set to the following standard values at the start of
| Register\[bits] | Setting |
|-|-|
| MXCSR\[6] | Denormals are zeros - 0 |
-| MXCSR\[7:12] | Exception masks all 1's (all exceptions masked) |
+| MXCSR\[7:12] | Exception masks all 1s (all exceptions masked) |
| MXCSR\[13:14] | Rounding control - 0 (round to nearest) |
| MXCSR\[15] | Flush to zero for masked underflow - 0 (off) |
A callee that modifies any of the nonvolatile fields within MXCSR must restore them before returning to its caller. Furthermore, a caller that has modified any of these fields must restore them to their standard values before invoking a callee, unless by agreement the callee expects the modified values.
-There are two exceptions to the rules about the non-volatility of the control flags:
+There are two exceptions to the rules about the nonvolatility of the control flags:
- In functions where the documented purpose of the given function is to modify the nonvolatile MXCSR flags.
@@ -205,10 +208,10 @@ Make no assumptions about the MXCSR register's volatile portion state across a f
## setjmp/longjmp
-When you include setjmpex.h or setjmp.h, all calls to [`setjmp`](../c-runtime-library/reference/setjmp.md) or [`longjmp`](../c-runtime-library/reference/longjmp.md) result in an unwind that invokes destructors and **`__finally`** calls. This behavior differs from x86, where including setjmp.h results in **`__finally`** clauses and destructors not being invoked.
+When you include `setjmpex.h` or `setjmp.h`, all calls to [`setjmp`](../c-runtime-library/reference/setjmp.md) or [`longjmp`](../c-runtime-library/reference/longjmp.md) result in an unwind that invokes destructors and `__finally` calls. This behavior differs from x86, where including `setjmp.h` results in `__finally` clauses and destructors not being invoked.
-A call to `setjmp` preserves the current stack pointer, non-volatile registers, and MXCSR registers. Calls to `longjmp` return to the most recent `setjmp` call site and resets the stack pointer, non-volatile registers, and MXCSR registers, back to the state as preserved by the most recent `setjmp` call.
+A call to `setjmp` preserves the current stack pointer, nonvolatile registers, and MXCSR registers. Calls to `longjmp` return to the most recent `setjmp` call site and resets the stack pointer, nonvolatile registers, and MXCSR registers, back to the state as preserved by the most recent `setjmp` call.
## See also
-[x64 software conventions](../build/x64-software-conventions.md)
+- [Overview of x64 ABI conventions](../build/x64-software-conventions.md)
diff --git a/docs/build/x64-software-conventions.md b/docs/build/x64-software-conventions.md
index d1136eff59..fe644a1aa5 100644
--- a/docs/build/x64-software-conventions.md
+++ b/docs/build/x64-software-conventions.md
@@ -1,7 +1,7 @@
---
description: "Learn more about: x64 ABI conventions"
title: "x64 ABI conventions"
-ms.date: 04/21/2022
+ms.date: 03/28/2025
helpviewer_keywords: ["x64 coding conventions", "x64 abi", "Visual C++, x64 calling conventions"]
---
# Overview of x64 ABI conventions
@@ -11,13 +11,16 @@ This topic describes the basic application binary interface (ABI) for x64, the 6
## x64 calling conventions
Two important differences between x86 and x64 are:
+
- 64-bit addressing capability
- Sixteen 64-bit registers for general use.
-Given the expanded register set, x64 uses the [__fastcall](../cpp/fastcall.md) calling convention and a RISC-based exception-handling model.
+Given the expanded register set, x64 uses the [`__fastcall`](../cpp/fastcall.md) calling convention and a RISC-based exception-handling model.
The **`__fastcall`** convention uses registers for the first four arguments, and the stack frame to pass more arguments. For details on the x64 calling convention, including register usage, stack parameters, return values, and stack unwinding, see [x64 calling convention](x64-calling-convention.md).
+For more information on the `__vectorcall` calling convention, see [`__vectorcall`](../cpp/vectorcall.md).
+
## Enable x64 compiler optimization
The following compiler option helps you optimize your application for x64:
@@ -114,7 +117,7 @@ _declspec(align(2)) struct {
}
```
-
+:::image type="content" source="../build/media/vcamd_conv_ex_1_block.png" alt-text="Diagram showing the structure layout for example 1. The diagram shows 2 bytes of memory. Member a, a short, occupies bytes 0 through 1.":::
#### Example 2
@@ -128,7 +131,9 @@ _declspec(align(8)) struct {
}
```
-
+:::image type="complex" source="../build/media/vcamd_conv_ex_2_block.png" alt-text="Diagram showing the structure layout for example 2.":::
+The diagram shows 24 bytes of memory. Member a, an int, occupies bytes 0 through 3. The diagram shows padding for bytes 4 through 7. Member b, a double, occupies bytes 8 through 15. Member c, a short, occupies bytes 16 through 17. Bytes 18 through 23 are unused.
+:::image-end:::
#### Example 3
@@ -143,7 +148,9 @@ _declspec(align(4)) struct {
}
```
-
+:::image type="complex" source="../build/media/vcamd_conv_ex_3_block.png" alt-text="Diagram showing the structure layout for example 3.":::
+The diagram shows 12 bytes of memory. Member a, a char, occupies byte 0. Byte 1 is padding. Member b, a short, occupies bytes 2 through 4. Member c, a char, occupies byte 4. Bytes 5 through 7 are padding. Member d, an int, occupies bytes 8 through 11.
+:::image-end:::
#### Example 4
@@ -157,7 +164,9 @@ _declspec(align(8)) union {
}
```
-
+:::image type="complex" source="../build/media/vcamd_conv_ex_4_block.png" alt-text="Diagram showing the union layout for example 4.":::
+The diagram shows 8 bytes of memory. Member p, a char, occupies byte 0. Member s, a short, occupies bytes 0 through 1. Member l, a long, occupies bytes 0 through 3. Bytes 4 through 7 are padding.
+:::image-end:::
### Bitfields
@@ -209,7 +218,7 @@ On function exit and on function entry to C Runtime Library calls and Windows sy
## Stack usage
-For details on stack allocation, alignment, function types and stack frames on x64, see [x64 stack usage](stack-usage.md).
+For details on stack allocation, alignment, function types, and stack frames on x64, see [x64 stack usage](stack-usage.md).
## Prolog and epilog
diff --git a/docs/c-language/array-declarations.md b/docs/c-language/array-declarations.md
index 53409bd05e..cf593aeb02 100644
--- a/docs/c-language/array-declarations.md
+++ b/docs/c-language/array-declarations.md
@@ -25,7 +25,7 @@ An "array declaration" names the array and specifies the type of its elements. I
*`declarator`*:\
*`pointer`*opt *`direct-declarator`*
-*`direct-declarator`*: /\* A function declarator \*/\
+*`direct-declarator`*:\
*`direct-declarator`* **`[`** *`constant-expression`*opt **`]`**
Because *`constant-expression`* is optional, the syntax has two forms:
diff --git a/docs/c-language/c-bit-fields.md b/docs/c-language/c-bit-fields.md
index d38c72c40e..ddd8fac1af 100644
--- a/docs/c-language/c-bit-fields.md
+++ b/docs/c-language/c-bit-fields.md
@@ -19,7 +19,7 @@ The *`constant-expression`* specifies the width of the field in bits. The *`type
Unnamed bit fields can't be referenced, and their contents at run time are unpredictable. They can be used as "dummy" fields, for alignment purposes. An unnamed bit field whose width is specified as 0 guarantees that storage for the member following it in the *struct-declaration-list* begins on an **`int`** boundary.
-Bit fields must also be long enough to contain the bit pattern. For example, these two statements aren't legal:
+The number of bits in a bit field must be less than or equal to the size of the underlying type. For example, these two statements aren't legal:
```C
short a:17; /* Illegal! */
@@ -72,7 +72,7 @@ the bits of `test` would be arranged as follows:
cccccccb bbbbaaaa
```
-Since the 8086 family of processors stores the low byte of integer values before the high byte, the integer `0x01F2` would be stored in physical memory as `0xF2` followed by `0x01`.
+Since the 8086 family of processors store the low byte of integer values before the high byte, the integer `0x01F2` would be stored in physical memory as `0xF2` followed by `0x01`.
The ISO C99 standard lets an implementation choose whether a bit field may straddle two storage instances. Consider this structure, which stores bit fields that total 64 bits:
diff --git a/docs/c-language/c-enumeration-declarations.md b/docs/c-language/c-enumeration-declarations.md
index 6f9153022e..08d1312b46 100644
--- a/docs/c-language/c-enumeration-declarations.md
+++ b/docs/c-language/c-enumeration-declarations.md
@@ -103,7 +103,7 @@ enum BOOLEAN end_flag, match_flag; /* Two variables of type BOOLEAN */
This declaration can also be specified as
```C
-enum BOOLEAN { false, true } end_flag, match_flag;\
+enum BOOLEAN { false, true } end_flag, match_flag;
```
or as
@@ -133,4 +133,4 @@ enum { yes, no } response;
## See also
-[Enumerations](../cpp/enumerations-cpp.md)
+[Enumerations(C++)](../cpp/enumerations-cpp.md)
diff --git a/docs/c-language/c-keywords.md b/docs/c-language/c-keywords.md
index 7ab089e397..37810945be 100644
--- a/docs/c-language/c-keywords.md
+++ b/docs/c-language/c-keywords.md
@@ -47,6 +47,8 @@ The C language uses the following keywords:
**`struct`**\
**`switch`**\
**`typedef`**\
+ **[`typeof`](typeof-c.md)**\
+ **[`typeof_unqual`](typeof-unqual-c.md)**\
**`union`**\
**`unsigned`**\
**`void`**\
@@ -67,12 +69,9 @@ The C language uses the following keywords:
:::column-end:::
:::row-end:::
-1 Keywords introduced in ISO C99.
-
-2 Keywords introduced in ISO C11.
-
-a Starting in Visual Studio 2019 version 16.8, these keywords are supported in code compiled as C when the **`/std:c11`** or **`/std:c17`** compiler options are specified.
-
+1 Keywords introduced in ISO C99.\
+2 Keywords introduced in ISO C11.\
+a Starting in Visual Studio 2019 version 16.8, these keywords are supported in code compiled as C when the **`/std:c11`** or **`/std:c17`** compiler options are specified.\
b Starting in Visual Studio 2019 version 16.8, these keywords are recognized but not supported by the compiler in code compiled as C when the **`/std:c11`** or **`/std:c17`** compiler options are specified.
You can't redefine keywords. However, you can specify text to replace keywords before compilation by using C [preprocessor directives](../preprocessor/preprocessor-directives.md).
@@ -105,6 +104,8 @@ The following keywords and special identifiers are recognized by the Microsoft C
:::column:::
**`__stdcall`**5\
**`__try`**5\
+ **[`__typeof__`](typeof-c.md)**\
+ **[`__typeof_unqual__`](typeof-unqual-c.md)**\
**`dllexport`**4\
**`dllimport`**4\
**`naked`**4\
@@ -113,17 +114,14 @@ The following keywords and special identifiers are recognized by the Microsoft C
:::column-end:::
:::row-end:::
-3 The **`__based`** keyword has limited uses for 32-bit and 64-bit target compilations.
-
-4 These are special identifiers when used with **`__declspec`**; their use in other contexts is unrestricted.
-
-5 For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.
-
+3 The **`__based`** keyword has limited uses for 32-bit and 64-bit target compilations.\
+4 These are special identifiers when used with **`__declspec`**; their use in other contexts is unrestricted.\
+5 For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.\
6 If you don't include , the Microsoft Visual C compiler maps **`static_assert`** to the C11 **`_Static_assert`** keyword.
-Microsoft extensions are enabled by default. To assist in creating portable code, you can disable Microsoft extensions by specifying the [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) option during compilation. When you use this option, some Microsoft-specific keywords are disabled.
+Microsoft extensions are enabled by default. To help create portable code, you can disable Microsoft extensions by specifying the [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) option during compilation. When you use this option, some Microsoft-specific keywords are disabled.
-When Microsoft extensions are enabled, you can use the keywords listed above in your programs. To conform to the language standard, most of these keywords are prefaced by a double underscore. The four exceptions, **`dllexport`**, **`dllimport`**, **`naked`**, and **`thread`**, are used only with **`__declspec`** and don't require a leading double underscore. For backward compatibility, single-underscore versions of the rest of the keywords are supported.
+When Microsoft extensions are enabled, you can use the keywords listed above in your programs. To conform to the language standard, most of these keywords have a leading double underscore. The four exceptions, **`dllexport`**, **`dllimport`**, **`naked`**, and **`thread`**, are used only with **`__declspec`** and don't require a leading double underscore. For backward compatibility, single-underscore versions of the rest of the keywords are supported.
## See also
diff --git a/docs/c-language/c-primary-expressions.md b/docs/c-language/c-primary-expressions.md
index 1b57eecbf0..b2939192a2 100644
--- a/docs/c-language/c-primary-expressions.md
+++ b/docs/c-language/c-primary-expressions.md
@@ -23,5 +23,5 @@ Primary expressions are the building blocks of more complex expressions. They ma
## See also
-[Generic selection](generic-selection.md)
+[Generic selection](generic-selection.md)\
[Operands and Expressions](../c-language/operands-and-expressions.md)
diff --git a/docs/c-language/c-type-specifiers.md b/docs/c-language/c-type-specifiers.md
index 92381bf7aa..a8ba159155 100644
--- a/docs/c-language/c-type-specifiers.md
+++ b/docs/c-language/c-type-specifiers.md
@@ -3,7 +3,6 @@ description: "Learn more about: C Type Specifiers"
title: "C Type Specifiers"
ms.date: "01/29/2018"
helpviewer_keywords: ["type specifiers, C", "specifiers, type"]
-ms.assetid: fbe13441-04c3-4829-b047-06d374adc2b6
---
# C Type Specifiers
@@ -55,7 +54,7 @@ The Microsoft C compiler also generates warnings for differences in sign. For ex
```C
signed int *pi;
-unsigned int *pu
+unsigned int *pu;
pi = pu; /* Now generates warning */
```
@@ -70,4 +69,6 @@ You can create more type specifiers with **`typedef`** declarations, as describe
## See also
-[Declarations and Types](../c-language/declarations-and-types.md)
+[Declarations and Types](../c-language/declarations-and-types.md)\
+[`typeof, __typeof__` (C23)](typeof-c.md)\
+[`typeof_unqual, __typeof_unqual__` (C23)](typeof-unqual-c.md)
\ No newline at end of file
diff --git a/docs/c-language/cpp-integer-limits.md b/docs/c-language/cpp-integer-limits.md
index 82ebf2660e..c860fb2336 100644
--- a/docs/c-language/cpp-integer-limits.md
+++ b/docs/c-language/cpp-integer-limits.md
@@ -23,7 +23,7 @@ Microsoft C also permits the declaration of sized integer variables, which are i
|**UCHAR_MAX**|Maximum value for a variable of type **`unsigned char`**.|255 (0xff)|
|**CHAR_MIN**|Minimum value for a variable of type **`char`**.|-128; 0 if /J option used|
|**CHAR_MAX**|Maximum value for a variable of type **`char`**.|127; 255 if /J option used|
-|**MB_LEN_MAX**|Maximum number of bytes in a multicharacter constant.|5|
+|**MB_LEN_MAX**|Maximum number of bytes in a multibyte character.|5|
|**SHRT_MIN**|Minimum value for a variable of type **`short`**.|-32768|
|**SHRT_MAX**|Maximum value for a variable of type **`short`**.|32767|
|**USHRT_MAX**|Maximum value for a variable of type **`unsigned short`**.|65535 (0xffff)|
diff --git a/docs/c-language/declarators-and-variable-declarations.md b/docs/c-language/declarators-and-variable-declarations.md
index 7e6b77ad58..d8c27aab0a 100644
--- a/docs/c-language/declarators-and-variable-declarations.md
+++ b/docs/c-language/declarators-and-variable-declarations.md
@@ -67,7 +67,7 @@ int list[20]; // Declares an array of 20 int values named list
char *cp; // Declares a pointer to a char value
double func( void ); // Declares a function named func, with no
// arguments, that returns a double value
-int *aptr[10] // Declares an array of 10 pointers
+int *aptr[10]; // Declares an array of 10 pointers
```
**Microsoft Specific**
diff --git a/docs/c-language/demotion-of-integers.md b/docs/c-language/demotion-of-integers.md
index f64f4104f9..5cc14b1695 100644
--- a/docs/c-language/demotion-of-integers.md
+++ b/docs/c-language/demotion-of-integers.md
@@ -25,7 +25,7 @@ char y = (char)0x1234;
assigns the value 0x34 to `y`.
-When **`signed`** variables are converted to **`unsigned`** and vice-versa, the bit patterns remain the same. For example, casting -2 (0xFE) to an **`unsigned`** value yields 254 (also 0xFE).
+When **`signed`** variables are converted to **`unsigned`** and vice-versa, the bit patterns remain the same. For example, casting -2 (0xFFFFFFFE) to an **`unsigned int`** value yields 4294967294 (also 0xFFFFFFFE).
## See also
diff --git a/docs/c-language/escape-sequences.md b/docs/c-language/escape-sequences.md
index 3b4b7b76a7..e1d271617f 100644
--- a/docs/c-language/escape-sequences.md
+++ b/docs/c-language/escape-sequences.md
@@ -34,7 +34,7 @@ Note that the question mark preceded by a backslash (**\\?**) specifies a litera
**Microsoft Specific**
-If a backslash precedes a character that does not appear in the table, the compiler handles the undefined character as the character itself. For example, `\c` is treated as an `c`.
+If a backslash precedes a character that does not appear in the table, the compiler handles the undefined character as the character itself. For example, `\c` is treated as a `c`.
**END Microsoft Specific**
diff --git a/docs/c-language/extern-storage-class-specifier.md b/docs/c-language/extern-storage-class-specifier.md
index 749c6227ae..fc53268609 100644
--- a/docs/c-language/extern-storage-class-specifier.md
+++ b/docs/c-language/extern-storage-class-specifier.md
@@ -1,9 +1,8 @@
---
-description: "Learn more about: extern Storage-Class Specifier"
title: "extern Storage-Class Specifier"
+description: "Learn more about: extern Storage-Class Specifier"
ms.date: "07/10/2018"
helpviewer_keywords: ["extern keyword [C]", "storage class specifiers, extern", "extern keyword [C], storage class specifier", "external linkage, storage-class specifiers", "external linkage, extern modifier"]
-ms.assetid: 6e16d927-291f-49e4-986c-9d91a482a441
---
# extern Storage-Class Specifier
@@ -14,12 +13,11 @@ A variable declared with the **`extern`** storage-class specifier is a reference
This example illustrates internal- and external-level declarations:
```c
-
// Source1.c
int i = 1;
-// Source2. c
+// Source2.c
#include
@@ -49,7 +47,7 @@ void func(void)
}
```
-In this example, the variable `i` is defined in Source1.c with an initial value of 1. An **`extern`** declaration in Source2.c is makes 'i' visible in that file.
+In this example, the variable `i` is defined in Source1.c with an initial value of 1. An **`extern`** declaration in Source2.c makes 'i' visible in that file.
In the `func` function, the address of the global variable `i` is used to initialize the **`static`** pointer variable `external_i`. This works because the global variable has **`static`** lifetime, meaning its address does not change during program execution. Next, a variable `i` is defined within the scope of `func` as a local variable with initial value 16. This definition does not affect the value of the external-level `i`, which is hidden by the use of its name for the local variable. The value of the global `i` is now accessible only through the pointer `external_i`.
diff --git a/docs/c-language/index.yml b/docs/c-language/index.yml
index feb5f6855e..3f038a096b 100644
--- a/docs/c-language/index.yml
+++ b/docs/c-language/index.yml
@@ -5,6 +5,7 @@ summary: Learn to use C and the C runtime library.
metadata:
title: C docs - get started, tutorials, reference.
description: C programming reference for users of Microsoft C/C++ and Visual Studio.
+ ms.author: twhitney
ms.topic: landing-page
ms.date: 05/28/2020
ms.custom: intro-landing-hub
diff --git a/docs/c-language/interpreting-more-complex-declarators.md b/docs/c-language/interpreting-more-complex-declarators.md
index d780d03e13..938504a381 100644
--- a/docs/c-language/interpreting-more-complex-declarators.md
+++ b/docs/c-language/interpreting-more-complex-declarators.md
@@ -47,31 +47,31 @@ In this example, the steps are numbered in order and can be interpreted as follo
The following examples illustrate other complex declarations and show how parentheses can affect the meaning of a declaration.
-```
+```C
int *var[5]; /* Array of pointers to int values */
```
The array modifier has higher priority than the pointer modifier, so `var` is declared to be an array. The pointer modifier applies to the type of the array elements; therefore, the array elements are pointers to **`int`** values.
-```
+```C
int (*var)[5]; /* Pointer to array of int values */
```
In this declaration for `var`, parentheses give the pointer modifier higher priority than the array modifier, and `var` is declared to be a pointer to an array of five **`int`** values.
-```
+```C
long *var( long, long ); /* Function returning pointer to long */
```
Function modifiers also have higher priority than pointer modifiers, so this declaration for `var` declares `var` to be a function returning a pointer to a **`long`** value. The function is declared to take two **`long`** values as arguments.
-```
+```C
long (*var)( long, long ); /* Pointer to function returning long */
```
This example is similar to the previous one. Parentheses give the pointer modifier higher priority than the function modifier, and `var` is declared to be a pointer to a function that returns a **`long`** value. Again, the function takes two **`long`** arguments.
-```
+```C
struct both /* Array of pointers to functions */
{ /* returning structures */
int a;
@@ -81,14 +81,14 @@ struct both /* Array of pointers to functions */
The elements of an array cannot be functions, but this declaration demonstrates how to declare an array of pointers to functions instead. In this example, `var` is declared to be an array of five pointers to functions that return structures with two members. The arguments to the functions are declared to be two structures with the same structure type, `both`. Note that the parentheses surrounding `*var[5]` are required. Without them, the declaration is an illegal attempt to declare an array of functions, as shown below:
-```
+```C
/* ILLEGAL */
struct both *var[5](struct both, struct both);
```
The following statement declares an array of pointers.
-```
+```C
unsigned int *(* const *name[5][10] ) ( void );
```
@@ -96,13 +96,13 @@ The `name` array has 50 elements organized in a multidimensional array. The elem
This next example is a function returning a pointer to an array of three **`double`** values.
-```
+```C
double ( *var( double (*)[3] ) )[3];
```
In this declaration, a function returns a pointer to an array, since functions returning arrays are illegal. Here `var` is declared to be a function returning a pointer to an array of three **`double`** values. The function `var` takes one argument. The argument, like the return value, is a pointer to an array of three **`double`** values. The argument type is given by a complex *abstract-declarator*. The parentheses around the asterisk in the argument type are required; without them, the argument type would be an array of three pointers to **`double`** values. For a discussion and examples of abstract declarators, see [Abstract Declarators](../c-language/c-abstract-declarators.md).
-```
+```C
union sign /* Array of arrays of pointers */
{ /* to pointers to unions */
int x;
@@ -112,7 +112,7 @@ union sign /* Array of arrays of pointers */
As the above example shows, a pointer can point to another pointer, and an array can contain arrays as elements. Here `var` is an array of five elements. Each element is a five-element array of pointers to pointers to unions with two members.
-```
+```C
union sign *(*var[5])[5]; /* Array of pointers to arrays
of pointers to unions */
```
diff --git a/docs/c-language/static-assert-c.md b/docs/c-language/static-assert-c.md
index dc8ab22981..0890f6594b 100644
--- a/docs/c-language/static-assert-c.md
+++ b/docs/c-language/static-assert-c.md
@@ -78,5 +78,5 @@ Windows SDK 10.0.20348.0 (version 2104) or later. For more information on instal
## See also
[`_STATIC_ASSERT` Macro](../c-runtime-library/reference/static-assert-macro.md)\
-[`assert` macro and `_assert` and `_wassert` functions](../c-runtime-library/reference/assert-macro-assert-wassert.md)
+[`assert` macro and `_assert` and `_wassert` functions](../c-runtime-library/reference/assert-macro-assert-wassert.md)\
[`/std` (Specify language standard version)](../build/reference/std-specify-language-standard-version.md)
diff --git a/docs/c-language/storage-and-alignment-of-structures.md b/docs/c-language/storage-and-alignment-of-structures.md
index 1032e70a32..e48c280822 100644
--- a/docs/c-language/storage-and-alignment-of-structures.md
+++ b/docs/c-language/storage-and-alignment-of-structures.md
@@ -27,7 +27,7 @@ where *n* is the packing size expressed with the /Zp[*n*] option and *item* is t
To use the `pack` pragma to specify packing other than the packing specified on the command line for a particular structure, give the `pack` pragma, where the packing size is 1, 2, 4, 8, or 16, before the structure. To reinstate the packing given on the command line, specify the `pack` pragma with no arguments.
-Bit fields default to size **`long`** for the Microsoft C compiler. Structure members are aligned on the size of the type or the /Zp[*n*] size, whichever is smaller. The default size is 4.
+For the Microsoft C compiler, bit fields default to a size of 4 bytes, which is a **`long`** data type. Structure members are aligned on the size of the type or the /Zp[*n*] size, whichever is smaller.
**END Microsoft Specific**
diff --git a/docs/c-language/storage-class-specifiers-for-external-level-declarations.md b/docs/c-language/storage-class-specifiers-for-external-level-declarations.md
index 7eb9b1d56b..c4b93d2c53 100644
--- a/docs/c-language/storage-class-specifiers-for-external-level-declarations.md
+++ b/docs/c-language/storage-class-specifiers-for-external-level-declarations.md
@@ -51,6 +51,7 @@ The example below illustrates external declarations:
#include
extern int i; // Reference to i, defined below
+extern void other ( void ); // Reference to other(), defined in second source file
void next( void ); // Function prototype
int main()
diff --git a/docs/c-language/toc.yml b/docs/c-language/toc.yml
index bdec148f7a..cfd26f82ed 100644
--- a/docs/c-language/toc.yml
+++ b/docs/c-language/toc.yml
@@ -171,6 +171,10 @@ items:
href: ../c-language/c-type-specifiers.md
- name: Data type specifiers and equivalents
href: ../c-language/data-type-specifiers-and-equivalents.md
+ - name: typeof
+ href: typeof-c.md
+ - name: typeof_unqual
+ href: typeof-unqual-c.md
- name: Type qualifiers
href: ../c-language/type-qualifiers.md
- name: Declarators and variable declarations
diff --git a/docs/c-language/typeof-c.md b/docs/c-language/typeof-c.md
new file mode 100644
index 0000000000..1537669942
--- /dev/null
+++ b/docs/c-language/typeof-c.md
@@ -0,0 +1,59 @@
+---
+title: "typeof, __typeof__ (C23)"
+description: "Describes Microsoft Visual C23 typeof operator"
+ms.date: 02/06/2024
+helpviewer_keywords: ["typeof keyword [C]", "__typeof__ keyword [C]"]
+---
+# `typeof`, `__typeof__` (C23)
+
+New in the C23 standard, the **`typeof`** operator is a unary operator that returns the type of an expression. It can be used in type declarations, type casts, type checks, and so on. It gets the type of a variable, function, or any C expression.
+
+The **`__typeof__`** keyword is a Microsoft-specific extension that provides the same functionality as **`typeof`**. The `__typeof__` keyword differs from `typeof` only in that it's available when compiling for all versions of C (not just `/std:clatest`), and it may ease porting code between other compilers that support `__typeof__`.
+
+### `typeof` syntax
+
+```c
+typeof(type)
+typeof(constant-expression)
+__typeof__(constant-expression)
+```
+
+### `typeof` example
+
+This example uses `typeof()`, but the behavior is the same if you use `__typeof__`.
+
+```c
+// Compile with /std:clatest
+
+#include
+
+double func()
+{
+ 3.14;
+}
+
+#define POINTER(T) typeof(T*)
+
+int main()
+{
+ auto a = func(); // the type for a (double) is inferred, but requires initialization at point of declaration
+ typeof(func()) b; // the type for b is double, but didn't have to be initialized at point of declaration
+
+ // Some declarations using typeof
+ POINTER(int) p1 = NULL; // p1 is int*
+
+ typeof(double(void))* pFunc = func; // pFunc is a pointer to a function that takes no arguments and returns a double
+ printf("pFunc() returns %f\n", pFunc());
+
+ return 0;
+}
+```
+
+## Requirements
+
+Requires Visual Studio 17.9 or later, or `cl.exe` version 19.39.33428 or later.
+To use `typeof`, compile with [`/std:clatest`](../build/reference/std-specify-language-standard-version.md).
+
+## See also
+
+[`/std` (Specify Language Standard Version)](../build/reference/std-specify-language-standard-version.md)
diff --git a/docs/c-language/typeof-unqual-c.md b/docs/c-language/typeof-unqual-c.md
new file mode 100644
index 0000000000..7786d9ecb8
--- /dev/null
+++ b/docs/c-language/typeof-unqual-c.md
@@ -0,0 +1,57 @@
+---
+title: "typeof_unqual, __typeof_unqual__ (C23)"
+description: "Describes Microsoft Visual C23 typeof_unqual operator"
+ms.date: 02/06/2024
+helpviewer_keywords: ["typeof_unqual keyword [C]", "__typeof_unqual__ keyword [C]"]
+---
+# `typeof_unqual`, `__typeof_unqual__` (C23)
+
+New in the C23 standard, the **`typeof_unqual`** operator is a unary operator that returns the type of an expression after discarding qualifiers such as `const`, `volatile`, and `restrict`. It can be used in type declarations, type casts, type checks, and so on. It gets the type of a variable, function, or any C expression.
+
+The **`__typeof_unqual__`** keyword is a Microsoft-specific extension that provides the same functionality as **`typeof_unqual`**. The **`__typeof_unqual__`** keyword differs from `typeof_unqual` only in that it's available when compiling for all versions of C (not just `/std:clatest`), and it may ease porting code between other compilers that support `__typeof_unqual__`.
+
+### `typeof_unqual` syntax
+
+```c
+typeof_unqual(type)
+typeof_unqual(constant-expression)
+__typeof__unqual(constant-expression)
+```
+
+### `typeof_unqual` example
+
+This example uses `typeof_unqual()`, but the behavior is the same if you use `__typeof_unqual__`.
+
+```c
+// Compile with /std:clatest and /experimental:c11atomics
+#include
+
+// A function that takes an atomic int pointer, but uses a non-atomic copy of the value
+void func(_Atomic(int) * pAtomic)
+{
+ typeof_unqual(*pAtomic) local = *pAtomic;
+
+ // Use local non-atomic copy of value
+}
+
+int main()
+{
+ int* const cpVar1 = 2;
+ typeof_unqual(cpVar1) pVar2 = 3;
+ pVar2 = 4; // no error because pi is not const. cpVar1 = 4 would be an error.
+
+ _Atomic(int)i = 42;
+ func(&i);
+
+ return 0;
+}
+```
+
+## Requirements
+
+Requires Visual Studio 17.9 or later, or `cl.exe` version 19.39.33428 or later.
+To use `typeof_unqual`, compile with [`/std:clatest`](../build/reference/std-specify-language-standard-version.md).
+
+## See also
+
+[`/std` (Specify Language Standard Version)](../build/reference/std-specify-language-standard-version.md)
diff --git a/docs/c-language/union-declarations.md b/docs/c-language/union-declarations.md
index 44e127a28d..7a0a0cd01e 100644
--- a/docs/c-language/union-declarations.md
+++ b/docs/c-language/union-declarations.md
@@ -81,7 +81,7 @@ Nested unions can be declared anonymously when they're members of another struct
struct str
{
int a, b;
- union / * Unnamed union */
+ union /* Unnamed union */
{
char c[4];
long l;
diff --git a/docs/c-runtime-library/buffer-manipulation.md b/docs/c-runtime-library/buffer-manipulation.md
index 21c4336737..7fce41ba6c 100644
--- a/docs/c-runtime-library/buffer-manipulation.md
+++ b/docs/c-runtime-library/buffer-manipulation.md
@@ -1,9 +1,8 @@
---
-description: "Learn more about: Buffer manipulation"
title: "Buffer manipulation"
-ms.date: "04/04/2018"
+description: "Learn more about: Buffer manipulation"
+ms.date: 04/04/2018
helpviewer_keywords: ["buffers, manipulation routines", "buffers"]
-ms.assetid: 164f4860-ce66-412c-8291-396fbd70f03e
---
# Buffer manipulation
@@ -13,17 +12,17 @@ Use these routines to work with areas of memory on a byte-by-byte basis.
| Routine | Use |
|---|---|
-| [`_memccpy`](./reference/memccpy.md) | Copy characters from one buffer to another until given character or given number of characters has been copied |
-| [`memchr`, `wmemchr`](./reference/memchr-wmemchr.md) | Return pointer to first occurrence, within specified number of characters, of given character in buffer |
-| [`memcmp`, `wmemcmp`](./reference/memcmp-wmemcmp.md) | Compare specified number of characters from two buffers |
-| [`memcpy`, `wmemcpy`](./reference/memcpy-wmemcpy.md), [`memcpy_s`, `wmemcpy_s`](./reference/memcpy-s-wmemcpy-s.md) | Copy specified number of characters from one buffer to another |
-| [`_memicmp`, `_memicmp_l`](./reference/memicmp-memicmp-l.md) | Compare specified number of characters from two buffers without regard to case |
-| [`memmove`, `wmemmove`](./reference/memmove-wmemmove.md),[`memmove_s`, `wmemmove_s`](./reference/memmove-s-wmemmove-s.md) | Copy specified number of characters from one buffer to another |
-| [`memset`, `wmemset`](./reference/memset-wmemset.md) | Use given character to initialize specified number of bytes in the buffer |
-| [`_swab`](./reference/swab.md) | Swap bytes of data and store them at specified location |
+| [`_memccpy`](reference/memccpy.md) | Copy characters from one buffer to another until given character or given number of characters has been copied |
+| [`memchr`, `wmemchr`](reference/memchr-wmemchr.md) | Return pointer to first occurrence, within specified number of characters, of given character in buffer |
+| [`memcmp`, `wmemcmp`](reference/memcmp-wmemcmp.md) | Compare specified number of characters from two buffers |
+| [`memcpy`, `wmemcpy`](reference/memcpy-wmemcpy.md), [`memcpy_s`, `wmemcpy_s`](reference/memcpy-s-wmemcpy-s.md) | Copy specified number of characters from one buffer to another |
+| [`_memicmp`, `_memicmp_l`](reference/memicmp-memicmp-l.md) | Compare specified number of characters from two buffers without regard to case |
+| [`memmove`, `wmemmove`](reference/memmove-wmemmove.md), [`memmove_s`, `wmemmove_s`](reference/memmove-s-wmemmove-s.md) | Copy specified number of characters from one buffer to another |
+| [`memset`, `wmemset`](reference/memset-wmemset.md) | Use given character to initialize specified number of bytes in the buffer |
+| [`_swab`](reference/swab.md) | Swap bytes of data and store them at specified location |
When the source and target areas overlap, only `memmove` is guaranteed to copy the full source properly.
## See also
-[Universal C runtime routines by category](./run-time-routines-by-category.md)
+[Universal C runtime routines by category](run-time-routines-by-category.md)
diff --git a/docs/c-runtime-library/byte-and-wide-streams.md b/docs/c-runtime-library/byte-and-wide-streams.md
index 634f4df7b8..8ef801bf6c 100644
--- a/docs/c-runtime-library/byte-and-wide-streams.md
+++ b/docs/c-runtime-library/byte-and-wide-streams.md
@@ -4,7 +4,6 @@ description: "An overview of byte streams in the Microsoft C runtime library."
ms.date: "11/04/2016"
ms.topic: "conceptual"
helpviewer_keywords: ["byte streams", "wide streams"]
-ms.assetid: 61ef0587-4cbc-4eb8-aae5-4c298dbbc6f9
---
# Byte and wide streams
@@ -12,7 +11,7 @@ A byte stream treats a file as a sequence of bytes. Within the program, the stre
By contrast, a wide stream treats a file as a sequence of generalized multibyte characters, which can have a broad range of encoding rules. (Text and binary files are still read and written as previously described.) Within the program, the stream looks like the corresponding sequence of wide characters. Conversions between the two representations occur within the Standard C Library. The conversion rules can, in principle, be altered by a call to [`setlocale`](./reference/setlocale-wsetlocale.md) that alters the category `LC_CTYPE`. Each wide stream determines its conversion rules at the time it becomes wide oriented, and retains these rules even if the category `LC_CTYPE` later changes.
-Positioning within a wide stream suffers the same limitations as for text steams. Moreover, the file-position indicator may well have to deal with a state-dependent encoding. Typically, it includes both a byte offset within the stream and an object of type `mbstate_t`. Thus, the only reliable way to obtain a file position within a wide stream is by calling [`fgetpos`](./reference/fgetpos.md), and the only reliable way to restore a position obtained this way is by calling [`fsetpos`](./reference/fsetpos.md).
+Positioning within a wide stream suffers the same limitations as for text streams. Moreover, the file-position indicator may well have to deal with a state-dependent encoding. Typically, it includes both a byte offset within the stream and an object of type `mbstate_t`. Thus, the only reliable way to obtain a file position within a wide stream is by calling [`fgetpos`](./reference/fgetpos.md), and the only reliable way to restore a position obtained this way is by calling [`fsetpos`](./reference/fsetpos.md).
## See also
diff --git a/docs/c-runtime-library/compatibility.md b/docs/c-runtime-library/compatibility.md
index e1c99c1d61..45f753bf02 100644
--- a/docs/c-runtime-library/compatibility.md
+++ b/docs/c-runtime-library/compatibility.md
@@ -33,6 +33,6 @@ Except as noted within the documentation for specific functions, the UCRT is com
| [UWP apps, the Windows Runtime, and the C runtime](./windows-store-apps-the-windows-runtime-and-the-c-run-time.md) | Describes when UCRT routines aren't compatible with Universal Windows apps or Microsoft Store apps. |
| [ANSI C conformance](./ansi-c-compliance.md) | Describes standard-conforming names in the UCRT. |
| [UNIX](./unix.md) | Provides guidelines for porting programs to UNIX. |
-| [Windows platforms (CRT)](./windows-platforms-crt.md) | Lists the operating systems that are the CRT supports. |
+| [Windows platforms (CRT)](./windows-platforms-crt.md) | Lists the operating systems that CRT supports. |
| [Backward compatibility](./backward-compatibility.md) | Describes how to map old CRT names to the new ones. |
| [C runtime (CRT) and C++ Standard Library (STL) `.lib` files](./crt-library-features.md) | Provides an overview of the CRT library (.lib) files and the associated compiler options. |
diff --git a/docs/c-runtime-library/crt-debug-heap-details.md b/docs/c-runtime-library/crt-debug-heap-details.md
index ffef146716..5a0d180c7d 100644
--- a/docs/c-runtime-library/crt-debug-heap-details.md
+++ b/docs/c-runtime-library/crt-debug-heap-details.md
@@ -102,14 +102,11 @@ typedef struct _CrtMemBlockHeader
The `no_mans_land` buffers on either side of the user data area of the block are currently 4 bytes in size, and are filled with a known byte value used by the debug heap routines to verify that the limits of the user's memory block haven't been overwritten. The debug heap also fills new memory blocks with a known value. If you elect to keep freed blocks in the heap's linked list, these freed blocks are also filled with a known value. Currently, the actual byte values used are as follows:
-`no_mans_land` (0xFD)\
-The "no_mans_land" buffers on either side of the memory used by an application are currently filled with 0xFD.
-
-Freed blocks (0xDD)\
-The freed blocks kept unused in the debug heap's linked list when the `_CRTDBG_DELAY_FREE_MEM_DF` flag is set are currently filled with 0xDD.
-
-New objects (0xCD)\
-New objects are filled with 0xCD when they're allocated.
+|Code |Description |
+|---------|---------|
+|`no_mans_land` (0xFD) | The "no_mans_land" buffers on either side of the memory used by an application are currently filled with 0xFD. |
+|Freed blocks (0xDD) | The freed blocks kept unused in the debug heap's linked list when the `_CRTDBG_DELAY_FREE_MEM_DF` flag is set are currently filled with 0xDD. |
+|New objects (0xCD) | New objects are filled with 0xCD when they're allocated.|
## Types of blocks on the debug heap
@@ -170,7 +167,7 @@ All calls to heap functions such as `malloc`, `free`, `calloc`, `realloc`, `new`
### To use the debug heap
-- Link the debug build of your application with a debug version of the C runtime library.
+Link the debug build of your application with a debug version of the C runtime library.
### To change one or more `_crtDbgFlag` bit fields and create a new state for the flag
@@ -275,9 +272,9 @@ Knowing the source file name and line number of an assert or reporting macro is
### Unique allocation request numbers and `_crtBreakAlloc`
-There's a simple way to identify the specific heap allocation call that went bad. It takes advantage of the unique allocation request number associated with each block in the debug heap. When information about a block is reported by one of the dump functions, this allocation request number is enclosed in braces (for example, "{36}").
+There's a simple way to identify the specific heap allocation call that went bad. It takes advantage of the unique allocation request number associated with each block in the debug heap. When information about a block is reported by one of the dump functions, this allocation request number is enclosed in braces. For example, `{36}`.
-Once you know the allocation request number of an improperly allocated block, you can pass this number to [`_CrtSetBreakAlloc`](./reference/crtsetbreakalloc.md) to create a breakpoint. Execution will break just before allocating the block, and you can backtrack to determine what routine was responsible for the bad call. To avoid recompiling, you can accomplish the same thing in the debugger by setting `_crtBreakAlloc` to the allocation request number you're interested in.
+Once you know the allocation request number of an improperly allocated block, you can pass this number to [`_CrtSetBreakAlloc`](./reference/crtsetbreakalloc.md) to create a breakpoint. Execution will break just before allocating the block and you can backtrack to determine what routine was responsible for the bad call. To avoid recompiling, you can accomplish the same thing in the debugger by setting `_crtBreakAlloc` to the allocation request number you're interested in.
### Creating debug versions of your allocation routines
diff --git a/docs/c-runtime-library/crt-debugging-techniques.md b/docs/c-runtime-library/crt-debugging-techniques.md
index a2379c0484..39d625f0e1 100644
--- a/docs/c-runtime-library/crt-debugging-techniques.md
+++ b/docs/c-runtime-library/crt-debugging-techniques.md
@@ -169,5 +169,5 @@ If the hook handles the message in question completely, so that no further repor
## See also
-- [Debugging Native Code](/visualstudio/debugger/debugging-native-code.md)
-- [Debugger Security](/visualstudio/debugger/debugger-security.md)
+- [Debugging Native Code](/visualstudio/debugger/debugging-native-code)
+- [Debugger Security](/visualstudio/debugger/debugger-security)
diff --git a/docs/c-runtime-library/crt-initialization.md b/docs/c-runtime-library/crt-initialization.md
index 705348bd86..b2971c1be1 100644
--- a/docs/c-runtime-library/crt-initialization.md
+++ b/docs/c-runtime-library/crt-initialization.md
@@ -4,7 +4,6 @@ description: "Describes how the CRT initializes global state in native code."
ms.topic: "conceptual"
ms.date: 08/02/2021
helpviewer_keywords: ["CRT initialization [C++]"]
-ms.assetid: e7979813-1856-4848-9639-f29c86b74ad7
---
# CRT initialization
@@ -16,9 +15,9 @@ It's possible, though not recommended, to take advantage of Microsoft-specific l
## Initializing a global object
-Consider the following code:
+Consider the following C++ code (C won't allow this code because it doesn't allow a function call in a constant expression).
-```C
+```cpp
int func(void)
{
return 3;
@@ -69,7 +68,6 @@ Offset Type Applied To Index Name
The CRT defines two pointers:
- `__xc_a` in `.CRT$XCA`
-
- `__xc_z` in `.CRT$XCZ`
Neither group has any other symbols defined except `__xc_a` and `__xc_z`.
@@ -88,7 +86,7 @@ The section should resemble this example:
__xc_z
```
-So, the CRT library uses both `__xc_a` and `__xc_z` to determine the start and end of the global initializers list because of the way in which they're laid out in memory after the image is loaded.
+The CRT library uses both `__xc_a` and `__xc_z` to determine the start and end of the global initializers list because of the way in which they're laid out in memory after the image is loaded.
## Linker features for initialization
@@ -112,4 +110,5 @@ The names `.CRT$XCT` and `.CRT$XCV` aren't used by either the compiler or the CR
## See also
+[`_initterm, _initterm_e`](./reference/initterm-initterm-e.md)\
[C runtime (CRT) and C++ Standard Library (STL) `.lib` files](./crt-library-features.md)
diff --git a/docs/c-runtime-library/crt-library-features.md b/docs/c-runtime-library/crt-library-features.md
index 93c60c2421..165f509086 100644
--- a/docs/c-runtime-library/crt-library-features.md
+++ b/docs/c-runtime-library/crt-library-features.md
@@ -3,7 +3,6 @@ title: "C runtime (CRT) and C++ standard library (STL) lib files"
description: "List of Microsoft C runtime and C++ standard library (STL) lib files that you can link against and their associated compiler options and preprocessor directives."
ms.date: "3/5/2021"
ms.topic: "reference"
-ms.custom: contperf-fy21q3
helpviewer_keywords: ["MSVCR71.dll", "libraries [C++], multithreaded", "library files, run-time", "LIBCMT.lib", "LIBCP.lib", "LIBCPMT.lib", "run-time libraries, C", "CRT, release versions", "MSVCP71.dll", "LIBC.lib", "libraries [C++]", "libraries [C++], run-time", "linking [C++], libraries", "STL libraries", "Microsoft standard template libraries"]
---
# C runtime (CRT) and C++ standard library (STL) `.lib` files
diff --git a/docs/c-runtime-library/data-alignment.md b/docs/c-runtime-library/data-alignment.md
index e9c8d32d66..97b03773fb 100644
--- a/docs/c-runtime-library/data-alignment.md
+++ b/docs/c-runtime-library/data-alignment.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Data Alignment"
title: "Data Alignment"
-ms.date: "11/04/2016"
+description: "Learn more about: Data Alignment"
+ms.date: 11/04/2016
f1_keywords: ["data.alignment"]
helpviewer_keywords: ["data alignment [C++]"]
-ms.assetid: 35ac3d2d-a4b3-421b-954f-b7372b1f18e1
---
# Data alignment
@@ -14,7 +13,7 @@ The following C run-time functions support data alignment.
| Routine | Use |
|---|---|
-| [`_aligned_free`](./reference/aligned-free.md) | Frees a block of memory that was allocated with [`_aligned_malloc`](./reference/aligned-malloc.md)or [`_aligned_offset_malloc`](./reference/aligned-offset-malloc.md). |
+| [`_aligned_free`](./reference/aligned-free.md) | Frees a block of memory that was allocated with [`_aligned_malloc`](./reference/aligned-malloc.md) or [`_aligned_offset_malloc`](./reference/aligned-offset-malloc.md). |
| [`_aligned_free_dbg`](./reference/aligned-free-dbg.md) | Frees a block of memory that was allocated with [`_aligned_malloc`](./reference/aligned-malloc.md) or [`_aligned_offset_malloc`](./reference/aligned-offset-malloc.md) (debug only). |
| [`_aligned_malloc`](./reference/aligned-malloc.md) | Allocates memory on a specified alignment boundary. |
| [`_aligned_malloc_dbg`](./reference/aligned-malloc-dbg.md) | Allocates memory on a specified alignment boundary with extra space for a debugging header and overwrite buffers (debug version only). |
diff --git a/docs/c-runtime-library/file-handling.md b/docs/c-runtime-library/file-handling.md
index 9ff1cf7924..661f7a0fb3 100644
--- a/docs/c-runtime-library/file-handling.md
+++ b/docs/c-runtime-library/file-handling.md
@@ -1,16 +1,15 @@
---
-description: "Learn more about: File Handling"
title: "File Handling"
-ms.date: "11/04/2016"
+description: "Learn more about: File Handling"
+ms.date: 11/04/2016
f1_keywords: ["c.files"]
helpviewer_keywords: ["files [C++], handling", "files [C++], opening", "files [C++], manipulating"]
-ms.assetid: 48119e2e-e94f-4602-b08b-b72440f731d8
---
# File handling
Use these routines to create, delete, and manipulate files and to set and check file-access permissions.
-The C run-time libraries have a 512 limit for the number of files that can be open at any one time. Attempting to open more than the maximum number of file descriptors or file streams causes program failure. Use [`_setmaxstdio`](./reference/setmaxstdio.md) to change this number.
+The C run-time libraries have a 512 limit for the number of files that can be open at any one time. Attempting to open more than the maximum number of file descriptors or file streams causes program failure. Use [`_setmaxstdio`](reference/setmaxstdio.md) to change this number.
## File-handling routines (file descriptor)
@@ -18,14 +17,14 @@ These routines operate on files designated by a file descriptor.
| Routine | Use |
|---|---|
-| [`_chsize`](./reference/chsize.md),[`_chsize_s`](./reference/chsize-s.md) | Change file size |
-| [`_filelength`, `_filelengthi64`](./reference/filelength-filelengthi64.md) | Get file length |
-| [`_fstat`, `_fstat32`, `_fstat64`, `_fstati64`, `_fstat32i64`, `_fstat64i32`](./reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32.md) | Get file-status information on descriptor |
-| [`_get_osfhandle`](./reference/get-osfhandle.md) | Return operating-system file handle associated with existing C run-time file descriptor |
-| [`_isatty`](./reference/isatty.md) | Check for character device |
-| [`_locking`](./reference/locking.md) | Lock areas of file |
-| [`_open_osfhandle`](./reference/open-osfhandle.md) | Associate C run-time file descriptor with existing operating-system file handle |
-| [`_setmode`](./reference/setmode.md) | Set file-translation mode |
+| [`_chsize`](reference/chsize.md), [`_chsize_s`](reference/chsize-s.md) | Change file size |
+| [`_filelength`, `_filelengthi64`](reference/filelength-filelengthi64.md) | Get file length |
+| [`_fstat`, `_fstat32`, `_fstat64`, `_fstati64`, `_fstat32i64`, `_fstat64i32`](reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32.md) | Get file-status information on descriptor |
+| [`_get_osfhandle`](reference/get-osfhandle.md) | Return operating-system file handle associated with existing C run-time file descriptor |
+| [`_isatty`](reference/isatty.md) | Check for character device |
+| [`_locking`](reference/locking.md) | Lock areas of file |
+| [`_open_osfhandle`](reference/open-osfhandle.md) | Associate C run-time file descriptor with existing operating-system file handle |
+| [`_setmode`](reference/setmode.md) | Set file-translation mode |
## File-Handling Routines (Path or Filename)
@@ -33,17 +32,17 @@ These routines operate on files specified by a path or filename.
| Routine | Use |
|---|---|
-| [`_access`, `_waccess`](./reference/access-waccess.md), [`_access_s`, `_waccess_s`](./reference/access-s-waccess-s.md) | Check file-permission setting |
-| [`_chmod`, `_wchmod`](./reference/chmod-wchmod.md) | Change file-permission setting |
-| [`_fullpath`, `_wfullpath`](./reference/fullpath-wfullpath.md) | Expand a relative path to its absolute path name |
-| [`_makepath`, `_wmakepath`](./reference/makepath-wmakepath.md), [`_makepath_s`, `_wmakepath_s`](./reference/makepath-s-wmakepath-s.md) | Merge path components into single, full path |
-| [`_mktemp`, `_wmktemp`](./reference/mktemp-wmktemp.md), [`_mktemp_s`, `_wmktemp_s`](./reference/mktemp-s-wmktemp-s.md) | Create unique filename |
-| [`remove`, `_wremove`](./reference/remove-wremove.md) | Delete file |
-| [`rename`, `_wrename`](./reference/rename-wrename.md) | Rename file |
-| [`_splitpath`, `_wsplitpath`](./reference/splitpath-wsplitpath.md), [`_splitpath_s`, `_wsplitpath_s`](./reference/splitpath-s-wsplitpath-s.md) | Parse path into components |
-| [`_stat`, `_stat64`, `_stati64`, `_wstat`, `_wstat64`, `_wstati64`](./reference/stat-functions.md) | Get file-status information on named file |
-| [`_umask`](./reference/umask.md), [`_umask_s`](./reference/umask-s.md) | Set default permission mask for new files created by program |
-| [`_unlink`, `_wunlink`](./reference/unlink-wunlink.md) | Delete file |
+| [`_access`, `_waccess`](reference/access-waccess.md), [`_access_s`, `_waccess_s`](reference/access-s-waccess-s.md) | Check file-permission setting |
+| [`_chmod`, `_wchmod`](reference/chmod-wchmod.md) | Change file-permission setting |
+| [`_fullpath`, `_wfullpath`](reference/fullpath-wfullpath.md) | Expand a relative path to its absolute path name |
+| [`_makepath`, `_wmakepath`](reference/makepath-wmakepath.md), [`_makepath_s`, `_wmakepath_s`](reference/makepath-s-wmakepath-s.md) | Merge path components into single, full path |
+| [`_mktemp`, `_wmktemp`](reference/mktemp-wmktemp.md), [`_mktemp_s`, `_wmktemp_s`](reference/mktemp-s-wmktemp-s.md) | Create unique filename |
+| [`remove`, `_wremove`](reference/remove-wremove.md) | Delete file |
+| [`rename`, `_wrename`](reference/rename-wrename.md) | Rename file |
+| [`_splitpath`, `_wsplitpath`](reference/splitpath-wsplitpath.md), [`_splitpath_s`, `_wsplitpath_s`](reference/splitpath-s-wsplitpath-s.md) | Parse path into components |
+| [`_stat`, `_stat64`, `_stati64`, `_wstat`, `_wstat64`, `_wstati64`](reference/stat-functions.md) | Get file-status information on named file |
+| [`_umask`](reference/umask.md), [`_umask_s`](reference/umask-s.md) | Set default permission mask for new files created by program |
+| [`_unlink`, `_wunlink`](reference/unlink-wunlink.md) | Delete file |
## File-Handling Routines (Open File)
@@ -51,32 +50,30 @@ These routines open files.
| Routine | Use |
|---|---|
-| [`fopen`, `_wfopen`](./reference/fopen-wfopen.md), [`fopen_s`, `_wfopen_s`](./reference/fopen-s-wfopen-s.md) | Opens a file and returns a pointer to the open file. |
-| [`_fsopen`, `_wfsopen`](./reference/fsopen-wfsopen.md) | Open a stream with file sharing and returns a pointer to the open file. |
-| [`_open`, `_wopen`](./reference/open-wopen.md) | Opens a file and returns a file descriptor to the opened file. |
-| [`_sopen`, `_wsopen`](./reference/sopen-wsopen.md), [`_sopen_s`, `_wsopen_s`](./reference/sopen-s-wsopen-s.md) | Open a file with file sharing and returns a file descriptor to the open file. |
-| [`_pipe`](./reference/pipe.md) | Creates a pipe for reading and writing. |
-| [`freopen`, `_wfreopen`](./reference/freopen-wfreopen.md), [`freopen_s`, `_wfreopen_s`](./reference/freopen-s-wfreopen-s.md) | Reassign a file pointer. |
+| [`fopen`, `_wfopen`](reference/fopen-wfopen.md), [`fopen_s`, `_wfopen_s`](reference/fopen-s-wfopen-s.md) | Opens a file and returns a pointer to the open file. |
+| [`_fsopen`, `_wfsopen`](reference/fsopen-wfsopen.md) | Open a stream with file sharing and returns a pointer to the open file. |
+| [`_open`, `_wopen`](reference/open-wopen.md) | Opens a file and returns a file descriptor to the opened file. |
+| [`_sopen`, `_wsopen`](reference/sopen-wsopen.md), [`_sopen_s`, `_wsopen_s`](reference/sopen-s-wsopen-s.md) | Open a file with file sharing and returns a file descriptor to the open file. |
+| [`_pipe`](reference/pipe.md) | Creates a pipe for reading and writing. |
+| [`freopen`, `_wfreopen`](reference/freopen-wfreopen.md), [`freopen_s`, `_wfreopen_s`](reference/freopen-s-wfreopen-s.md) | Reassign a file pointer. |
These routines provide a way to change the representation of the file between a `FILE` structure, a file descriptor, and a Win32 file handle.
| Routine | Use |
|---|---|
-| [`_fdopen`, `_wfdopen`](./reference/fdopen-wfdopen.md) | Associates a stream with a file that was previously opened for low-level I/O and returns a pointer to the open stream. |
-| [`_fileno`](./reference/fileno.md) | Gets the file descriptor associated with a stream. |
-| [`_get_osfhandle`](./reference/get-osfhandle.md) | Return operating-system file handle associated with existing C run-time file descriptor |
-| [`_open_osfhandle`](./reference/open-osfhandle.md) | Associates C run-time file descriptor with an existing operating-system file handle. |
+| [`_fdopen`, `_wfdopen`](reference/fdopen-wfdopen.md) | Associates a stream with a file that was previously opened for low-level I/O and returns a pointer to the open stream. |
+| [`_fileno`](reference/fileno.md) | Gets the file descriptor associated with a stream. |
+| [`_get_osfhandle`](reference/get-osfhandle.md) | Return operating-system file handle associated with existing C run-time file descriptor |
+| [`_open_osfhandle`](reference/open-osfhandle.md) | Associates C run-time file descriptor with an existing operating-system file handle. |
The following Win32 functions also open files and pipes:
- [`CreateFile`](/windows/win32/api/fileapi/nf-fileapi-createfilew)
-
- [`CreatePipe`](/windows/win32/api/namedpipeapi/nf-namedpipeapi-createpipe)
-
- [`CreateNamedPipe`](/windows/win32/api/winbase/nf-winbase-createnamedpipea)
## See also
-[Universal C runtime routines by category](./run-time-routines-by-category.md)\
-[Directory control](./directory-control.md)\
-[System calls](./system-calls.md)
+[Universal C runtime routines by category](run-time-routines-by-category.md)\
+[Directory control](directory-control.md)\
+[System calls](system-calls.md)
diff --git a/docs/c-runtime-library/find-memory-leaks-using-the-crt-library.md b/docs/c-runtime-library/find-memory-leaks-using-the-crt-library.md
index dea101aead..1e78d27ce5 100644
--- a/docs/c-runtime-library/find-memory-leaks-using-the-crt-library.md
+++ b/docs/c-runtime-library/find-memory-leaks-using-the-crt-library.md
@@ -2,7 +2,7 @@
title: Find memory leaks with the CRT library
description: Learn how the C/C++ debugger and C Run-time Library (CRT) can help find memory leaks. The techniques include memory-leak reports and comparing memory snapshots.
ms.date: 02/03/2023
-helpviewer_keywords:
+helpviewer_keywords:
- breakpoints, on memory allocation
- _CrtMemState
- _CrtMemCheckpoint
@@ -165,7 +165,7 @@ struct Pod {
int x;
};
-void main() {
+int main() {
Pod* pPod = DBG_NEW Pod;
pPod = DBG_NEW Pod; // Oops, leaked the original pPod!
delete pPod;
@@ -216,7 +216,7 @@ You can use the allocation number to set a breakpoint on the memory allocation.
After you set a breakpoint on a memory-allocation number, continue to debug. Make sure to run under the same conditions, so the memory-allocation number doesn't change. When your program breaks at the specified memory allocation, use the **Call Stack** window and other debugger windows to determine the conditions under which the memory was allocated. Then, you can continue execution to observe what happens to the object and determine why it isn't correctly deallocated.
-Setting a data breakpoint on the object might also be helpful. For more information, see [Using breakpoints](/visualstudio/debugger/using-breakpoints.md).
+Setting a data breakpoint on the object might also be helpful. For more information, see [Using breakpoints](/visualstudio/debugger/using-breakpoints).
You can also set memory-allocation breakpoints in code. You can set:
@@ -241,7 +241,7 @@ _CrtMemCheckpoint( &s1 );
The `_CrtMemCheckpoint` function fills in the structure with a snapshot of the current memory state.
-To output the contents of a `_CrtMemState` structure, pass the structure to the `_ CrtMemDumpStatistics` function:
+To output the contents of a `_CrtMemState` structure, pass the structure to the `_CrtMemDumpStatistics` function:
```cpp
_CrtMemDumpStatistics( &s1 );
@@ -281,5 +281,5 @@ One technique for finding memory leaks begins by placing `_CrtMemCheckpoint` cal
## See also
- [CRT debug heap details](./crt-debug-heap-details.md)
-- [Debugger security](/visualstudio/debugger/debugger-security.md)
-- [Debugging native code](/visualstudio/debugger/debugging-native-code.md)
+- [Debugger security](/visualstudio/debugger/debugger-security)
+- [Debugging native code](/visualstudio/debugger/debugging-native-code)
diff --git a/docs/c-runtime-library/floating-point-support.md b/docs/c-runtime-library/floating-point-support.md
index 69a51ce7ce..7f4ac7bc98 100644
--- a/docs/c-runtime-library/floating-point-support.md
+++ b/docs/c-runtime-library/floating-point-support.md
@@ -11,7 +11,9 @@ The Universal C Runtime library (UCRT) provides many integral and floating-point
For ISO C Standard 11 (C11) and later, the `` header, in addition to including `` and ``, provides macros that invoke a corresponding math function based on the types of the parameters. See [Type-generic math](tgmath.md) for details.
-Many of the floating point math library functions have different implementations for different CPU architectures. For example, the 32-bit x86 CRT may have a different implementation than the 64-bit x64 CRT. In addition, some of the functions may have multiple implementations for a given CPU architecture. The most efficient implementation is selected dynamically at run-time depending on the instruction sets supported by the CPU. For example, in the 32-bit x86 CRT, some functions have both an x87 implementation and an SSE2 implementation. When running on a CPU that supports SSE2, the faster SSE2 implementation is used. When running on a CPU that doesn't support SSE2, the slower x87 implementation is used. Because different implementations of the math library functions may use different CPU instructions and different algorithms to produce their results, the functions may produce different results across CPUs. In most cases, the results are within +/-1 ULP of the correctly rounded result, but the actual results may vary across CPUs.
+Many of the floating-point math library functions have different implementations for different CPU architectures. For example, the 32-bit x86 CRT may have a different implementation than the 64-bit x64 CRT. In addition, some of the functions may have multiple implementations for a given CPU architecture. The most efficient implementation is selected dynamically at run-time depending on the instruction sets supported by the CPU. For example, in the 32-bit x86 CRT, some functions have both an x87 implementation and an SSE2 implementation. When running on a CPU that supports SSE2, the faster SSE2 implementation is used. When running on a CPU that doesn't support SSE2, the slower x87 implementation is used. Because different implementations of the math library functions may use different CPU instructions and different algorithms to produce their results, the functions may produce different results across CPUs. In most cases, the results are within +/-1 ULP of the correctly rounded result, but the actual results may vary across CPUs.
+
+Newer versions of the UCRT might improve the precision and accuracy of the floating-point math library functions. Since the UCRT is part of the Windows operating system, you might get different results for these functions on different operating system versions or between debug and release builds. Although it is not recommended, you can statically link to the UCRT to guarantee consistent results if you need these functions will produce identical results everywhere.
Previous 16-bit versions of Microsoft C/C++ and Microsoft Visual C++ supported the **`long double`** type as an 80-bit precision floating-point data type. In later versions of Visual C++, the **`long double`** data type is a 64-bit precision floating-point data type identical to the **`double`** type. The compiler treats **`long double`** and **`double`** as distinct types, but the **`long double`** functions are identical to their **`double`** counterparts. The CRT provides **`long double`** versions of the math functions for ISO C99 source code compatibility, but note that the binary representation may differ from other compilers.
@@ -79,7 +81,7 @@ Previous 16-bit versions of Microsoft C/C++ and Microsoft Visual C++ supported t
| [`imaxabs`](./reference/imaxabs.md) | Computes the absolute value of an integer type |
| [`imaxdiv`](./reference/imaxdiv.md) | Computes the quotient and the remainder of two integer values |
| [`isfinite`, `_finite`, `_finitef`](./reference/finite-finitef.md) | Determines whether a value is finite |
-| [`isgreater`, `isgreaterequal`, `isless`, `islessequal`, `islessgreater`, `isunordered`](./reference/floating-point-ordering.md) | Compare the order of two floating point values |
+| [`isgreater`, `isgreaterequal`, `isless`, `islessequal`, `islessgreater`, `isunordered`](./reference/floating-point-ordering.md) | Compare the order of two floating-point values |
| [`isinf`](./reference/isinf.md) | Determines whether a floating-point value is infinite |
| [`isnan`, `_isnan`, `_isnanf`](./reference/isnan-isnan-isnanf.md) | Tests a floating-point value for NaN |
| [`isnormal`](./reference/isnormal.md) | Tests whether a floating-point value is both finite and not subnormal |
diff --git a/docs/c-runtime-library/format-specification-fields-scanf-and-wscanf-functions.md b/docs/c-runtime-library/format-specification-fields-scanf-and-wscanf-functions.md
index bf5994d104..ee57428b23 100644
--- a/docs/c-runtime-library/format-specification-fields-scanf-and-wscanf-functions.md
+++ b/docs/c-runtime-library/format-specification-fields-scanf-and-wscanf-functions.md
@@ -3,7 +3,6 @@ description: "Learn more about: Format specification fields: scanf and wscanf fu
title: "Format specification fields: scanf and wscanf functions"
ms.date: 05/13/2022
ms.topic: "reference"
-ms.custom: contperf-fy21q1
helpviewer_keywords: ["width, specifications in scanf function", "scanf format specifications", "scanf width specifications", "scanf type field characters", "type fields, scanf function", "format specification fields for scanf function", "type fields"]
---
# Format specification fields: `scanf` and `wscanf` functions
diff --git a/docs/c-runtime-library/heapset.md b/docs/c-runtime-library/heapset.md
index 98b435fbb4..71dcd09725 100644
--- a/docs/c-runtime-library/heapset.md
+++ b/docs/c-runtime-library/heapset.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _heapset"
title: "_heapset"
+description: "Learn more about: _heapset"
ms.date: "11/04/2016"
api_name: ["_heapset"]
api_location: ["msvcr90.dll", "msvcr80.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcrt.dll", "msvcr120.dll", "msvcr100.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_heapset", "heapset"]
helpviewer_keywords: ["checking heap", "heapset function", "heaps, checking", "debugging [CRT], heap-related problems", "_heapset function"]
-ms.assetid: 9667eeb0-55bc-4c19-af5f-d1fd0a142b3c
---
# `_heapset`
@@ -47,7 +46,7 @@ In addition, if an error occurs, **`_heapset`** sets `errno` to `ENOSYS`.
The **`_heapset`** function shows free memory locations or nodes that have been unintentionally overwritten.
-**`_heapset`** checks for minimal consistency on the heap and then sets each byte of the heap's free entries to the `fill` value. This known value shows which memory locations of the heap contain free nodes and which contain data that were unintentionally written to freed memory. If the operating system doesn't support **`_heapset`**(for example, Windows 98), the function returns `_HEAPOK` and sets `errno` to `ENOSYS`.
+**`_heapset`** checks for minimal consistency on the heap and then sets each byte of the heap's free entries to the `fill` value. This known value shows which memory locations of the heap contain free nodes and which contain data that were unintentionally written to freed memory. If the operating system doesn't support **`_heapset`** (for example, Windows 98), the function returns `_HEAPOK` and sets `errno` to `ENOSYS`.
## Requirements
diff --git a/docs/c-runtime-library/iob.md b/docs/c-runtime-library/iob.md
index 6029c1d1f8..9341f6b617 100644
--- a/docs/c-runtime-library/iob.md
+++ b/docs/c-runtime-library/iob.md
@@ -1,14 +1,13 @@
---
description: "Learn more about: _iob"
title: "_iob"
-ms.date: "11/04/2016"
+ms.date: 07/10/2023
api_name: ["_iob"]
api_location: ["msvcrt.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_iob", "_IOB_ENTRIES", "STDIO/_IOB_ENTRIES"]
helpviewer_keywords: ["_iob global variable", "iob global variable"]
-ms.assetid: 008ed376-8078-4bbd-bc6c-0677c63d0ff1
---
# `_iob`
@@ -22,8 +21,12 @@ FILE _iob[_IOB_ENTRIES];
## Remarks
-`_IOB_ENTRIES` is defined as 3 in `stdio.h`.
+Starting with Visual Studio 2015, `_IOB_ENTRIES` is defined as 3 with the introduction of the Universal CRT.
+It was previously defined as 20.
+
+Defined in `stdio.h`.
## See also
-[Global variables](./global-variables.md)
+[Global variables](./global-variables.md)\
+[Introducing the Universal CRT](https://devblogs.microsoft.com/cppblog/introducing-the-universal-crt/)
diff --git a/docs/c-runtime-library/is-isw-routines.md b/docs/c-runtime-library/is-isw-routines.md
index ed95473112..749a96439b 100644
--- a/docs/c-runtime-library/is-isw-routines.md
+++ b/docs/c-runtime-library/is-isw-routines.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: is, isw Routines"
title: "is, isw Routines"
+description: "Learn more about: is, isw Routines"
ms.date: 01/11/2022
helpviewer_keywords: ["is routines", "isw routines"]
---
@@ -15,7 +15,7 @@ helpviewer_keywords: ["is routines", "isw routines"]
[`iscntrl`, `iswcntrl`, `_iscntrl_l`, `_iswcntrl_l`](./reference/iscntrl-iswcntrl-iscntrl-l-iswcntrl-l.md)\
[`iscsym`, `iscsymf`, `__iscsym`, `__iswcsym`, `__iscsymf`, `__iswcsymf`, `_iscsym_l`, `_iswcsym_l`, `_iscsymf_l`, `_iswcsymf_l`](./reference/iscsym-functions.md)\
[`_isctype`, `iswctype`, `_isctype_l`, `_iswctype_l`](./reference/isctype-iswctype-isctype-l-iswctype-l.md)\
- [`isdigit`, `iswdigit`, `_isdigit_l`, `_iswdigit_l`](./reference/isdigit-iswdigit-isdigit-l-iswdigit-l.md)
+ [`isdigit`, `iswdigit`, `_isdigit_l`, `_iswdigit_l`](./reference/isdigit-iswdigit-isdigit-l-iswdigit-l.md)\
[`isgraph`, `iswgraph`, `_isgraph_l`, `_iswgraph_l`](./reference/isgraph-iswgraph-isgraph-l-iswgraph-l.md)\
[`isleadbyte`, `_isleadbyte_l`](./reference/isleadbyte-isleadbyte-l.md)\
[`islower`, `iswlower`, `_islower_l`, `_iswlower_l`](./reference/islower-iswlower-islower-l-iswlower-l.md)\
diff --git a/docs/c-runtime-library/ismbc-routines.md b/docs/c-runtime-library/ismbc-routines.md
index b941bbcf3c..7c7a33362c 100644
--- a/docs/c-runtime-library/ismbc-routines.md
+++ b/docs/c-runtime-library/ismbc-routines.md
@@ -1,41 +1,40 @@
---
-description: "Learn more about: _ismbc Routines"
title: "_ismbc Routines"
+description: "Learn more about: _ismbc Routines"
ms.date: "11/04/2016"
helpviewer_keywords: ["ismbc routines", "_ismbc routines"]
-ms.assetid: b8995391-7857-4ac3-9a1e-de946eb4464d
---
# `_ismbc` routines
Each `_ismbc` routine tests a given multibyte character `c` for a particular condition.
-- [`_ismbcalnum`, `_ismbcalnum_l`, `_ismbcalpha`, `_ismbcalpha_l`, `_ismbcdigit`, `_ismbcdigit_l`](./reference/ismbcalnum-functions.md)\
-- [`_ismbcl0`, `_ismbcl0_l`, `_ismbcl1`, `_ismbcl1_l`, `_ismbcl2`, `_ismbcl2_l`](./reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md)\
-- [`_ismbcgraph`, `_ismbcgraph_l`, `_ismbcprint`, `_ismbcprint_l`, `_ismbcpunct`, `_ismbcpunct_l`, `_ismbcblank`, `_ismbcblank_l`, `_ismbcspace`, `_ismbcspace_l`](./reference/ismbcgraph-functions.md)\
-- [`_ismbclegal`, `_ismbclegal_l`, `_ismbcsymbol`, `_ismbcsymbol_l`](./reference/ismbclegal-ismbclegal-l-ismbcsymbol-ismbcsymbol-l.md)\
-- [`_ismbchira`, `_ismbchira_l`, `_ismbckata`, `_ismbckata_l`](./reference/ismbchira-ismbchira-l-ismbckata-ismbckata-l.md)\
-- [`_ismbclower`, `_ismbclower_l`, `_ismbcupper`, `_ismbcupper_l`](./reference/ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md)
+- [`_ismbcalnum`, `_ismbcalnum_l`, `_ismbcalpha`, `_ismbcalpha_l`, `_ismbcdigit`, `_ismbcdigit_l`](reference/ismbcalnum-functions.md)
+- [`_ismbcl0`, `_ismbcl0_l`, `_ismbcl1`, `_ismbcl1_l`, `_ismbcl2`, `_ismbcl2_l`](reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md)
+- [`_ismbcgraph`, `_ismbcgraph_l`, `_ismbcprint`, `_ismbcprint_l`, `_ismbcpunct`, `_ismbcpunct_l`, `_ismbcblank`, `_ismbcblank_l`, `_ismbcspace`, `_ismbcspace_l`](reference/ismbcgraph-functions.md)
+- [`_ismbclegal`, `_ismbclegal_l`, `_ismbcsymbol`, `_ismbcsymbol_l`](reference/ismbclegal-ismbclegal-l-ismbcsymbol-ismbcsymbol-l.md)
+- [`_ismbchira`, `_ismbchira_l`, `_ismbckata`, `_ismbckata_l`](reference/ismbchira-ismbchira-l-ismbckata-ismbckata-l.md)
+- [`_ismbclower`, `_ismbclower_l`, `_ismbcupper`, `_ismbcupper_l`](reference/ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md)
## Remarks
-The test result of each `_ismbc` routine depends on the multibyte code page in effect. Multibyte code pages have single-byte alphabetic characters. By default, the multibyte code page is set to the system-default ANSI code page obtained from the operating system at program startup. You can query or change the multibyte code page in use with [`_getmbcp`](./reference/getmbcp.md) or [`_setmbcp`](./reference/setmbcp.md), respectively.
+The test result of each `_ismbc` routine depends on the multibyte code page in effect. Multibyte code pages have single-byte alphabetic characters. By default, the multibyte code page is set to the system-default ANSI code page obtained from the operating system at program startup. You can query or change the multibyte code page in use with [`_getmbcp`](reference/getmbcp.md) or [`_setmbcp`](reference/setmbcp.md), respectively.
-The output value is affected by the `LC_CTYPE` category setting of the locale. For more information, see [`setlocale`](./reference/setlocale-wsetlocale.md). The versions of these functions without the `_l` suffix use the current locale for this locale-dependent behavior; the versions with the `_l` suffix are identical except that they use the locale parameter passed in instead.
+The output value is affected by the `LC_CTYPE` category setting of the locale. For more information, see [`setlocale`](reference/setlocale-wsetlocale.md). The versions of these functions without the `_l` suffix use the current locale for this locale-dependent behavior; the versions with the `_l` suffix are identical except that they use the locale parameter passed in instead.
| Routine | Test condition | Code page 932 example |
|---|---|---|
-| [`_ismbcalnum`, `_ismbcalnum_l`](./reference/ismbcalnum-functions.md) | Alphanumeric | Returns nonzero if and only if `c` is a single-byte representation of an ASCII English letter: See examples for `_ismbcdigit` and `_ismbcalpha`. |
-| [`_ismbcalpha`, `_ismbcalpha_l`](./reference/ismbcalnum-functions.md) | Alphabetic | Returns nonzero if and only if `c` is a single-byte representation of an ASCII English letter: See examples for `_ismbcupper` and `_ismbclower`; or a katakana letter: 0xA6<=`c`<=0xDF. |
-| [`_ismbcdigit`, `_ismbcdigit_l`](./reference/ismbcalnum-functions.md) | Digit | Returns nonzero if and only if `c` is a single-byte representation of an ASCII digit: 0x30<=`c`<=0x39. |
-| [`_ismbcgraph`, `_ismbcgraph_l`](./reference/ismbcgraph-functions.md) | Graphic | Returns nonzero if and only if `c` is a single-byte representation of any ASCII or katakana printable character except a white space ( ). See examples for `_ismbcdigit`, `_ismbcalpha`, and `_ismbcpunct`. |
-| [`_ismbclegal`, `_ismbclegal_l`](./reference/ismbclegal-ismbclegal-l-ismbcsymbol-ismbcsymbol-l.md) | Valid multibyte character | Returns nonzero if and only if the first byte of `c` is within ranges 0x81 - 0x9F or 0xE0 - 0xFC, while the second byte is within ranges 0x40 - 0x7E or 0x80 - FC. |
-| [`_ismbclower`, `_ismbclower_l`](./reference/ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md) | Lowercase alphabetic | Returns nonzero if and only if `c` is a single-byte representation of an ASCII lowercase English letter: 0x61<=`c`<=0x7A. |
-| [`_ismbcprint`, `_ismbcprint_l`](./reference/ismbcgraph-functions.md) | Printable | Returns nonzero if and only if `c` is a single-byte representation of any ASCII or katakana printable character including a white space ( ): See examples for `_ismbcspace`, `_ismbcdigit`, `_ismbcalpha`, and `_ismbcpunct`. |
-| [`_ismbcpunct`, `_ismbcpunct_l`](./reference/ismbcgraph-functions.md) | Punctuation | Returns nonzero if and only if `c` is a single-byte representation of any ASCII or katakana punctuation character. |
-| [`_ismbcblank`, `_ismbcblank_l`](./reference/ismbcgraph-functions.md) | Space or horizontal tab | Returns nonzero if and only if `c` is a single-byte representation of a space character or a horizontal tab character: `c`=0x20 or `c`=0x09. |
-| [`_ismbcspace`, `_ismbcspace_l`](./reference/ismbcgraph-functions.md) | Whitespace | Returns nonzero if and only if `c` is a white space character: `c`=0x20 or 0x09<=`c`<=0x0D. |
-| [`_ismbcsymbol`, `_ismbcsymbol_l`](./reference/ismbclegal-ismbclegal-l-ismbcsymbol-ismbcsymbol-l.md) | Multibyte symbol | Returns nonzero if and only if 0x8141<=`c`<=0x81AC. |
-| [`_ismbcupper`, `_ismbcupper_l`](./reference/ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md) | Uppercase alphabetic | Returns nonzero if and only if `c` is a single-byte representation of an ASCII uppercase English letter: 0x41<=`c`<=0x5A. |
+| [`_ismbcalnum`, `_ismbcalnum_l`](reference/ismbcalnum-functions.md) | Alphanumeric | Returns nonzero if and only if `c` is a single-byte representation of an ASCII English letter: See examples for `_ismbcdigit` and `_ismbcalpha`. |
+| [`_ismbcalpha`, `_ismbcalpha_l`](reference/ismbcalnum-functions.md) | Alphabetic | Returns nonzero if and only if `c` is a single-byte representation of an ASCII English letter: See examples for `_ismbcupper` and `_ismbclower`; or a katakana letter: 0xA6<=`c`<=0xDF. |
+| [`_ismbcdigit`, `_ismbcdigit_l`](reference/ismbcalnum-functions.md) | Digit | Returns nonzero if and only if `c` is a single-byte representation of an ASCII digit: 0x30<=`c`<=0x39. |
+| [`_ismbcgraph`, `_ismbcgraph_l`](reference/ismbcgraph-functions.md) | Graphic | Returns nonzero if and only if `c` is a single-byte representation of any ASCII or katakana printable character except a white space ( ). See examples for `_ismbcdigit`, `_ismbcalpha`, and `_ismbcpunct`. |
+| [`_ismbclegal`, `_ismbclegal_l`](reference/ismbclegal-ismbclegal-l-ismbcsymbol-ismbcsymbol-l.md) | Valid multibyte character | Returns nonzero if and only if the first byte of `c` is within ranges 0x81 - 0x9F or 0xE0 - 0xFC, while the second byte is within ranges 0x40 - 0x7E or 0x80 - FC. |
+| [`_ismbclower`, `_ismbclower_l`](reference/ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md) | Lowercase alphabetic | Returns nonzero if and only if `c` is a single-byte representation of an ASCII lowercase English letter: 0x61<=`c`<=0x7A. |
+| [`_ismbcprint`, `_ismbcprint_l`](reference/ismbcgraph-functions.md) | Printable | Returns nonzero if and only if `c` is a single-byte representation of any ASCII or katakana printable character including a white space ( ): See examples for `_ismbcspace`, `_ismbcdigit`, `_ismbcalpha`, and `_ismbcpunct`. |
+| [`_ismbcpunct`, `_ismbcpunct_l`](reference/ismbcgraph-functions.md) | Punctuation | Returns nonzero if and only if `c` is a single-byte representation of any ASCII or katakana punctuation character. |
+| [`_ismbcblank`, `_ismbcblank_l`](reference/ismbcgraph-functions.md) | Space or horizontal tab | Returns nonzero if and only if `c` is a single-byte representation of a space character or a horizontal tab character: `c`=0x20 or `c`=0x09. |
+| [`_ismbcspace`, `_ismbcspace_l`](reference/ismbcgraph-functions.md) | Whitespace | Returns nonzero if and only if `c` is a white space character: `c`=0x20 or 0x09<=`c`<=0x0D. |
+| [`_ismbcsymbol`, `_ismbcsymbol_l`](reference/ismbclegal-ismbclegal-l-ismbcsymbol-ismbcsymbol-l.md) | Multibyte symbol | Returns nonzero if and only if 0x8141<=`c`<=0x81AC. |
+| [`_ismbcupper`, `_ismbcupper_l`](reference/ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md) | Uppercase alphabetic | Returns nonzero if and only if `c` is a single-byte representation of an ASCII uppercase English letter: 0x41<=`c`<=0x5A. |
**Code Page 932 Specific**
@@ -43,18 +42,18 @@ The following routines are specific to code page 932.
| Routine | Test condition (code page 932 only) |
|---|---|
-| [`_ismbchira`, `_ismbchira_l`](./reference/ismbchira-ismbchira-l-ismbckata-ismbckata-l.md) | Double-byte Hiragana: 0x829F<=`c`<=0x82F1. |
-| [`_ismbckata`, `_ismbckata_l`](./reference/ismbchira-ismbchira-l-ismbckata-ismbckata-l.md) | Double-byte katakana: 0x8340<=`c`<=0x8396. |
-| [`_ismbcl0`, `_ismbcl0_l`](./reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md) | JIS non-Kanji: 0x8140<=`c`<=0x889E. |
-| [`_ismbcl1`, `_ismbcl1_l`](./reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md) | JIS level-1: 0x889F<=`c`<=0x9872. |
-| [`_ismbcl2`, `_ismbcl2_l`](./reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md) | JIS level-2: 0x989F<=`c`<=0xEA9E. |
+| [`_ismbchira`, `_ismbchira_l`](reference/ismbchira-ismbchira-l-ismbckata-ismbckata-l.md) | Double-byte Hiragana: 0x829F<=`c`<=0x82F1. |
+| [`_ismbckata`, `_ismbckata_l`](reference/ismbchira-ismbchira-l-ismbckata-ismbckata-l.md) | Double-byte katakana: 0x8340<=`c`<=0x8396. |
+| [`_ismbcl0`, `_ismbcl0_l`](reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md) | JIS non-Kanji: 0x8140<=`c`<=0x889E. |
+| [`_ismbcl1`, `_ismbcl1_l`](reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md) | JIS level-1: 0x889F<=`c`<=0x9872. |
+| [`_ismbcl2`, `_ismbcl2_l`](reference/ismbcl0-ismbcl0-l-ismbcl1-ismbcl1-l-ismbcl2-ismbcl2-l.md) | JIS level-2: 0x989F<=`c`<=0xEA9E. |
-`_ismbcl0`, `_ismbcl1`, and `_ismbcl2` check that the specified value `c` matches the test conditions described in the preceding table, but don't check that `c` is a valid multibyte character. If the lower byte is in the ranges 0x00 - 0x3F, 0x7F, or 0xFD - 0xFF, these functions return a nonzero value, indicating that the character satisfies the test condition. Use [`_ismbbtrail`, `_ismbbtrail_l`](./reference/ismbbtrail-ismbbtrail-l.md) to test whether the multibyte character is defined.
+`_ismbcl0`, `_ismbcl1`, and `_ismbcl2` check that the specified value `c` matches the test conditions described in the preceding table, but don't check that `c` is a valid multibyte character. If the lower byte is in the ranges 0x00 - 0x3F, 0x7F, or 0xFD - 0xFF, these functions return a nonzero value, indicating that the character satisfies the test condition. Use [`_ismbbtrail`, `_ismbbtrail_l`](reference/ismbbtrail-ismbbtrail-l.md) to test whether the multibyte character is defined.
**END Code Page 932 Specific**
## See also
-[Character classification](./character-classification.md)\
-[`is`, `isw` routines](./is-isw-routines.md)\
-[`_ismbb` routines](./ismbb-routines.md)
+[Character classification](character-classification.md)\
+[`is`, `isw` routines](is-isw-routines.md)\
+[`_ismbb` routines](ismbb-routines.md)
diff --git a/docs/c-runtime-library/language-strings.md b/docs/c-runtime-library/language-strings.md
index c68c721c29..99b9af3a15 100644
--- a/docs/c-runtime-library/language-strings.md
+++ b/docs/c-runtime-library/language-strings.md
@@ -6,7 +6,7 @@ helpviewer_keywords: ["language strings"]
---
# Language strings
-The [`setlocale`](./reference/setlocale-wsetlocale.md) and [`_create_locale`](./reference/create-locale-wcreate-locale.md) functions can use the Windows NLS API supported languages on operating systems that don't use the Unicode code page. For a list of supported languages by operating system version, see [Appendix A: Product Behavior](/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c) in \[MS-LCID]: Windows Language Code Identifier (LCID) Reference. The language string can be any of the values in the **Language** and **Language tag** columns of the list of supported languages. For example code that enumerates available locale names and related values, see [NLS: Name-based APIs Sample](/windows/win32/intl/nls--name-based-apis-sample).
+The [`setlocale`](reference/setlocale-wsetlocale.md) and [`_create_locale`](reference/create-locale-wcreate-locale.md) functions can use the Windows NLS API supported languages on operating systems that don't use the Unicode code page. For a list of supported languages by operating system version, see [Appendix A: Product Behavior](/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c) in \[MS-LCID]: Windows Language Code Identifier (LCID) Reference. The language string can be any of the values in the **Language** and **Language tag** columns of the list of supported languages. For example code that enumerates available locale names and related values, see [NLS: Name-based APIs Sample](/windows/win32/intl/nls--name-based-apis-sample).
## Supported language strings
@@ -82,7 +82,7 @@ The Microsoft C run-time library implementation also supports these language str
## See also
-- [Locale names, Languages, and Country/Region strings](./locale-names-languages-and-country-region-strings.md)\
-- [Country/Region strings](./country-region-strings.md)\
-- [`setlocale`, `_wsetlocale`](./reference/setlocale-wsetlocale.md)\
-- [`_create_locale`, `_wcreate_locale`](./reference/create-locale-wcreate-locale.md)
+- [Locale names, Languages, and Country/Region strings](locale-names-languages-and-country-region-strings.md)
+- [Country/Region strings](country-region-strings.md)
+- [`setlocale`, `_wsetlocale`](reference/setlocale-wsetlocale.md)
+- [`_create_locale`, `_wcreate_locale`](reference/create-locale-wcreate-locale.md)
diff --git a/docs/c-runtime-library/link-options.md b/docs/c-runtime-library/link-options.md
index 33a73b92de..7f27f9a178 100644
--- a/docs/c-runtime-library/link-options.md
+++ b/docs/c-runtime-library/link-options.md
@@ -1,27 +1,26 @@
---
-description: "Learn more about: Link Options"
-title: "Link Options"
+title: "Link options"
+description: "Learn more about: Link options"
ms.date: "11/04/2016"
helpviewer_keywords: ["nothrownew.obj", "newmode.obj", "noenv.obj", "psetargv.obj", "legacy_stdio_float_rounding.obj", "loosefpmath.obj", "smallheap.obj", "fp10.obj", "nochkclr.obj", "chkstk.obj", "pcommode.obj", "pnoenv.obj", "link options [C++]", "invalidcontinue.obj", "pnothrownew.obj", "pwsetargv.obj", "pinvalidcontinue.obj", "wsetargv.obj", "binmode.obj", "setargv.obj", "noarg.obj", "pnewmode.obj", "commode.obj", "pthreadlocale.obj", "pbinmode.obj", "threadlocale.obj", "pnoarg.obj"]
-ms.assetid: 05b5a77b-9dd1-494b-ae46-314598c770bb
---
# Link options
-The CRT lib directory includes several small object files that enable specific CRT features without any code change. These object files are called "link options" since you only have to add them to the linker command line to use them.
+The CRT lib directory includes several small object files that enable specific CRT features without code changes. These object files are called "link options" because you only have to add them to the linker command line to use them. To do this from Visual Studio, in the Solution Explorer right-click your project and choose **Properties**. Under **Configuration Properties**, choose **Linker** > **Input** > **Additional Dependencies** and specify the additional items to add to the link command line.
-CLR pure mode versions of these objects are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017. Use the regular versions for native and /clr code.
+CLR pure mode versions of these objects are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017. Use the regular versions for native and [`/clr`](../build/reference/clr-common-language-runtime-compilation.md) code.
| Native and /clr | Pure mode | Description |
|---|---|---|
-| `binmode.obj` | `pbinmode.obj` | Sets the default file-translation mode to binary. See [`_fmode`](./fmode.md). |
+| `binmode.obj` | `pbinmode.obj` | Sets the default file-translation mode to binary. See [`_fmode`](fmode.md). |
| `chkstk.obj` | n/a | Provides stack-checking and alloca support when not using the CRT. |
-| `commode.obj` | `pcommode.obj` | Sets the global commit flag to "commit". See [`fopen`, `_wfopen`](./reference/fopen-wfopen.md) and [`fopen_s`, `_wfopen_s`](./reference/fopen-s-wfopen-s.md). |
-| exe_initialize_mta.lib | n/a | Initializes the MTA apartment during EXE startup, which allows the use of COM objects in global smart pointers. Because this option leaks an MTA apartment reference during shutdown, don't use it for DLLs. Linking to this file is equivalent to including `combase.h` and defining `_EXE_INITIALIZE_MTA`. Using this link option adds [onecore.lib](/windows/win32/apiindex/windows-umbrella-libraries) to the default library list. If this effect is undesirable (such as using onecore_apiset.lib or other umbrella library), use [/NODEFAULTLIB](../build/reference/nodefaultlib-ignore-libraries.md) to override this behavior and provide an alternative. |
-| `fp10.obj` | n/a | Changes the default precision control to 64 bits. See [Math and floating-point support](./floating-point-support.md). |
+| `commode.obj` | `pcommode.obj` | Sets the global commit flag to "commit". See [`fopen`, `_wfopen`](reference/fopen-wfopen.md) and [`fopen_s`, `_wfopen_s`](reference/fopen-s-wfopen-s.md). |
+| `exe_initialize_mta.lib` | n/a | Initializes the MTA apartment during EXE startup, which allows the use of COM objects in global smart pointers. Because this option leaks an MTA apartment reference during shutdown, don't use it for DLLs. Linking to this file is equivalent to including `combase.h` and defining `_EXE_INITIALIZE_MTA`. Using this link option adds [`onecore.lib`](/windows/win32/apiindex/windows-umbrella-libraries) to the default library list. If this effect is undesirable (such as using onecore_apiset.lib or other umbrella library), use [`/NODEFAULTLIB`](../build/reference/nodefaultlib-ignore-libraries.md) to override this behavior and provide an alternative. |
+| `fp10.obj` | n/a | Changes the default precision control to 64 bits. See [Math and floating-point support](floating-point-support.md). |
| `invalidcontinue.obj` | `pinvalidcontinue.obj` | Sets a default invalid parameter handler that does nothing, meaning that invalid parameters passed to CRT functions will just set errno and return an error result. |
-| `legacy_stdio_float_rounding.obj` | n/a | The printing of floating-point values (for example, when using [`printf`](./reference/printf-printf-l-wprintf-wprintf-l.md)) with the Windows 10 19041 Universal C Runtime has been fixed. It now properly rounds exactly representable floating-point numbers, and respects the floating-point rounding requested by [`fesetround`](./reference/fegetround-fesetround2.md). This behavior update is available in Visual Studio 2019 version 16.2 and later. Legacy behavior is used in earlier versions of Visual Studio, or by providing this link option. |
+| `legacy_stdio_float_rounding.obj` | n/a | The printing of floating-point values (for example, when using [`printf`](reference/printf-printf-l-wprintf-wprintf-l.md)) with the Windows 10 19041 Universal C Runtime has been fixed. It now properly rounds exactly representable floating-point numbers, and respects the floating-point rounding requested by [`fesetround`](reference/fegetround-fesetround2.md). This behavior update is available in Visual Studio 2019 version 16.2 and later. Legacy behavior is used in earlier versions of Visual Studio, or by providing this link option. |
| `loosefpmath.obj` | n/a | Ensures that floating point code tolerates denormal values. |
-| `newmode.obj` | `pnewmode.obj` | Causes [`malloc`](./reference/malloc.md) to call the new handler on failure. See [`_set_new_mode`](./reference/set-new-mode.md), [`_set_new_handler`](./reference/set-new-handler.md), [`calloc`](./reference/calloc.md), and [`realloc`](./reference/realloc.md). |
+| `newmode.obj` | `pnewmode.obj` | Causes [`malloc`](reference/malloc.md) to call the new handler on failure. See [`_set_new_mode`](reference/set-new-mode.md), [`_set_new_handler`](reference/set-new-handler.md), [`calloc`](reference/calloc.md), and [`realloc`](reference/realloc.md). |
| `noarg.obj` | `pnoarg.obj` | Disables all processing of argc and argv. |
| `nochkclr.obj` | n/a | Does nothing. Remove from your project. |
| `noenv.obj` | `pnoenv.obj` | Disables the creation of a cached environment for the CRT. |
@@ -32,4 +31,4 @@ CLR pure mode versions of these objects are deprecated in Visual Studio 2015 and
## See also
-- [C runtime (CRT) and C++ Standard Library (STL) `.lib` files](./crt-library-features.md)
+- [C runtime (CRT) and C++ Standard Library (STL) `.lib` files](crt-library-features.md)
diff --git a/docs/c-runtime-library/locale.md b/docs/c-runtime-library/locale.md
index f7ced3c342..5801ca774e 100644
--- a/docs/c-runtime-library/locale.md
+++ b/docs/c-runtime-library/locale.md
@@ -1,63 +1,63 @@
---
-description: "Learn more about: Locale"
title: "Locale"
-ms.date: "04/11/2018"
+description: "Learn more about: Locale"
+ms.date: 04/11/2018
f1_keywords: ["c.international"]
helpviewer_keywords: ["localization, locale", "country/region information", "language information routines", "setlocale function", "locale routines"]
---
# Locale
-*Locale* refers to country/region and language settings that you can use to customize your program. Some locale-dependent categories include the display formats for dates and monetary values. For more information, see [Locale categories](./locale-categories.md).
+*Locale* refers to country/region and language settings that you can use to customize your program. Some locale-dependent categories include the display formats for dates and monetary values. For more information, see [Locale categories](locale-categories.md).
-Use the [`setlocale`](./reference/setlocale-wsetlocale.md) function to change or query some or all of the current program or thread locale information while using functions without the **`_l`** suffix. The functions with the **`_l`** suffix will use the locale parameter passed in for their locale information during the execution of that specific function only. To create a locale for use with a function with a **`_l`** suffix, use [`_create_locale`](./reference/create-locale-wcreate-locale.md). To free this locale, use [`_free_locale`](./reference/free-locale.md). To get the current locale, use [`_get_current_locale`](./reference/get-current-locale.md).
+Use the [`setlocale`](reference/setlocale-wsetlocale.md) function to change or query some or all of the current program or thread locale information while using functions without the **`_l`** suffix. The functions with the **`_l`** suffix will use the locale parameter passed in for their locale information during the execution of that specific function only. To create a locale for use with a function with a **`_l`** suffix, use [`_create_locale`](reference/create-locale-wcreate-locale.md). To free this locale, use [`_free_locale`](reference/free-locale.md). To get the current locale, use [`_get_current_locale`](reference/get-current-locale.md).
-Use [`_configthreadlocale`](./reference/configthreadlocale.md) to control whether each thread has its own locale, or all threads in a program share the same locale. For more information, see [Locales and code pages](../text/locales-and-code-pages.md).
+Use [`_configthreadlocale`](reference/configthreadlocale.md) to control whether each thread has its own locale, or all threads in a program share the same locale. For more information, see [Locales and code pages](../text/locales-and-code-pages.md).
-More secure versions of the functions in the following table are available, indicated by the **`_s`** ("secure") suffix. For more information, see [Security features in the CRT](./security-features-in-the-crt.md).
+More secure versions of the functions in the following table are available, indicated by the **`_s`** ("secure") suffix. For more information, see [Security features in the CRT](security-features-in-the-crt.md).
## Locale-dependent routines
| Routine | Use | **`setlocale`** category setting dependence |
|---|---|---|
-| [`atof`, `_atof_l`, `_wtof`, `_wtof_l`](./reference/atof-atof-l-wtof-wtof-l.md) | Convert character to floating-point value | `LC_NUMERIC` |
-| [`atoi`, `_atoi_l`, `_wtoi`, `_wtoi_l`](./reference/atoi-atoi-l-wtoi-wtoi-l.md) | Convert character to integer value | `LC_NUMERIC` |
-| [`_atoi64`, `_atoi64_l`, `_wtoi64`, `_wtoi64_l`](./reference/atoi64-atoi64-l-wtoi64-wtoi64-l.md) | Convert character to 64-bit integer value | `LC_NUMERIC` |
-| [`atol`, `_atol_l`, `_wtol`, `_wtol_l`](./reference/atol-atol-l-wtol-wtol-l.md) | Convert character to long value | `LC_NUMERIC` |
-| [`_atodbl`, `_atodbl_l`, `_atoldbl`, `_atoldbl_l`, `_atoflt`, `_atoflt_l`](./reference/atodbl-atodbl-l-atoldbl-atoldbl-l-atoflt-atoflt-l.md) | Convert character to double-long value | `LC_NUMERIC` |
-| [`is`, `isw` routines](./is-isw-routines.md) | Test given integer for particular condition. | `LC_CTYPE` |
-| [`isleadbyte`, `_isleadbyte_l`](./reference/isleadbyte-isleadbyte-l.md) | Test for lead byte | `LC_CTYPE` |
-| [`localeconv`](./reference/localeconv.md) | Read appropriate values for formatting numeric quantities | `LC_MONETARY, LC_NUMERIC` |
-| [`MB_CUR_MAX`](./mb-cur-max.md) | Maximum length in bytes of any multibyte character in current locale (macro defined in `STDLIB.H`) | `LC_CTYPE` |
-| [`_mbccpy`, `_mbccpy_l`](./reference/mbccpy-mbccpy-l.md),[`_mbccpy_s`, `_mbccpy_s_l`](./reference/mbccpy-s-mbccpy-s-l.md) | Copy one multibyte character | `LC_CTYPE` |
-| [`_mbclen`, `mblen`, `_mblen_l`](./reference/mbclen-mblen-mblen-l.md) | Validate and return number of bytes in multibyte character | `LC_CTYPE` |
-| [`strlen`, `wcslen`, `_mbslen`, `_mbslen_l`, `_mbstrlen`, `_mbstrlen_l`](./reference/strlen-wcslen-mbslen-mbslen-l-mbstrlen-mbstrlen-l.md) | For multibyte-character strings: validate each character in string; return string length | `LC_CTYPE` |
-| [`mbstowcs`, `_mbstowcs_l`](./reference/mbstowcs-mbstowcs-l.md),[`mbstowcs_s`, `_mbstowcs_s_l`](./reference/mbstowcs-s-mbstowcs-s-l.md) | Convert sequence of multibyte characters to corresponding sequence of wide characters | `LC_CTYPE` |
-| [`mbtowc`, `_mbtowc_l`](./reference/mbtowc-mbtowc-l.md) | Convert multibyte character to corresponding wide character | `LC_CTYPE` |
-| [`printf`](./reference/printf-printf-l-wprintf-wprintf-l.md) functions | Write formatted output | `LC_NUMERIC` (determines radix character output) |
-| [`scanf`](./reference/scanf-scanf-l-wscanf-wscanf-l.md) functions | Read formatted input | `LC_NUMERIC` (determines radix character recognition) |
-| [`setlocale`, `_wsetlocale`](./reference/setlocale-wsetlocale.md) | Select locale for program | Not applicable |
-| [`strcoll`, `wcscoll`, `_mbscoll`, `_strcoll_l`, `_wcscoll_l`, `_mbscoll_l`](./reference/strcoll-wcscoll-mbscoll-strcoll-l-wcscoll-l-mbscoll-l.md) | Compare characters of two strings | `LC_COLLATE` |
-| [`_stricmp`, `_wcsicmp`, `_mbsicmp`, `_stricmp_l`, `_wcsicmp_l`, `_mbsicmp_l`](./reference/stricmp-wcsicmp-mbsicmp-stricmp-l-wcsicmp-l-mbsicmp-l.md) | Compare two strings without regard to case | `LC_CTYPE` |
-| [`_stricoll`, `_wcsicoll`, `_mbsicoll`, `_stricoll_l`, `_wcsicoll_l`, `_mbsicoll_l`](./reference/stricoll-wcsicoll-mbsicoll-stricoll-l-wcsicoll-l-mbsicoll-l.md) | Compare characters of two strings (case insensitive) | `LC_COLLATE` |
-| [`_strncoll`, `_wcsncoll`, `_mbsncoll`, `_strncoll_l`, `_wcsncoll_l`, `_mbsncoll_l`](./reference/strncoll-wcsncoll-mbsncoll-strncoll-l-wcsncoll-l-mbsncoll-l.md) | Compare first **`n`** characters of two strings | `LC_COLLATE` |
-| [`_strnicmp`, `_wcsnicmp`, `_mbsnicmp`, `_strnicmp_l`, `_wcsnicmp_l`, `_mbsnicmp_l`](./reference/strnicmp-wcsnicmp-mbsnicmp-strnicmp-l-wcsnicmp-l-mbsnicmp-l.md) | Compare characters of two strings without regard to case. | `LC_CTYPE` |
-| [`_strnicoll`, `_wcsnicoll`, `_mbsnicoll`, `_strnicoll_l`, `_wcsnicoll_l`, `_mbsnicoll_l`](./reference/strnicoll-wcsnicoll-mbsnicoll-strnicoll-l-wcsnicoll-l-mbsnicoll-l.md) | Compare first **`n`** characters of two strings (case insensitive) | `LC_COLLATE` |
-| [`strftime`, `wcsftime`, `_strftime_l`, `_wcsftime_l`](./reference/strftime-wcsftime-strftime-l-wcsftime-l.md) | Format date and time value according to supplied **`format`** argument | `LC_TIME` |
-| [`_strlwr`, `_wcslwr`, `_mbslwr`, `_strlwr_l`, `_wcslwr_l`, `_mbslwr_l`](./reference/strlwr-wcslwr-mbslwr-strlwr-l-wcslwr-l-mbslwr-l.md),[`_strlwr_s`, `_strlwr_s_l`, `_mbslwr_s`, `_mbslwr_s_l`, `_wcslwr_s`, `_wcslwr_s_l`](./reference/strlwr-s-strlwr-s-l-mbslwr-s-mbslwr-s-l-wcslwr-s-wcslwr-s-l.md) | Convert, in place, each uppercase letter in given string to lowercase | `LC_CTYPE` |
-| [`strtod`, `_strtod_l`, `wcstod`, `_wcstod_l`](./reference/strtod-strtod-l-wcstod-wcstod-l.md) | Convert character string to **`double`** value | `LC_NUMERIC` (determines radix character recognition) |
-| [`strtol`, `wcstol`, `_strtol_l`, `_wcstol_l`](./reference/strtol-wcstol-strtol-l-wcstol-l.md) | Convert character string to **`long`** value | `LC_NUMERIC` (determines radix character recognition) |
-| [`strtoul`, `_strtoul_l`, `wcstoul`, `_wcstoul_l`](./reference/strtoul-strtoul-l-wcstoul-wcstoul-l.md) | Convert character string to unsigned long value | `LC_NUMERIC` (determines radix character recognition) |
-| [`_strupr`, `_strupr_l`, `_mbsupr`, `_mbsupr_l`, `_wcsupr_l`, `_wcsupr`](./reference/strupr-strupr-l-mbsupr-mbsupr-l-wcsupr-l-wcsupr.md),[`_strupr_s`, `_strupr_s_l`, `_mbsupr_s`, `_mbsupr_s_l`, `_wcsupr_s`, `_wcsupr_s_l`](./reference/strupr-s-strupr-s-l-mbsupr-s-mbsupr-s-l-wcsupr-s-wcsupr-s-l.md) | Convert, in place, each lowercase letter in string to uppercase | `LC_CTYPE` |
-| [`strxfrm`, `wcsxfrm`, `_strxfrm_l`, `_wcsxfrm_l`](./reference/strxfrm-wcsxfrm-strxfrm-l-wcsxfrm-l.md) | Transform string into collated form according to locale | `LC_COLLATE` |
-| [`tolower`, `_tolower`, `towlower`, `_tolower_l`, `_towlower_l`](./reference/tolower-tolower-towlower-tolower-l-towlower-l.md),[`_mbctolower`, `_mbctolower_l`, `_mbctoupper`, `_mbctoupper_l`](./reference/mbctolower-mbctolower-l-mbctoupper-mbctoupper-l.md) | Convert given character to corresponding lowercase character | `LC_CTYPE` |
-| [`toupper`, `_toupper`, `towupper`, `_toupper_l`, `_towupper_l`](./reference/toupper-toupper-towupper-toupper-l-towupper-l.md),[`_mbctolower`, `_mbctolower_l`, `_mbctoupper`, `_mbctoupper_l`](./reference/mbctolower-mbctolower-l-mbctoupper-mbctoupper-l.md) | Convert given character to corresponding uppercase letter | `LC_CTYPE` |
-| [`wcstombs`, `_wcstombs_l`](./reference/wcstombs-wcstombs-l.md),[`wcstombs_s`, `_wcstombs_s_l`](./reference/wcstombs-s-wcstombs-s-l.md) | Convert sequence of wide characters to corresponding sequence of multibyte characters | `LC_CTYPE` |
-| [`wctomb`, `_wctomb_l`](./reference/wctomb-wctomb-l.md),[`wctomb_s`, `_wctomb_s_l`](./reference/wctomb-s-wctomb-s-l.md) | Convert wide character to corresponding multibyte character | `LC_CTYPE` |
+| [`atof`, `_atof_l`, `_wtof`, `_wtof_l`](reference/atof-atof-l-wtof-wtof-l.md) | Convert character to floating-point value | `LC_NUMERIC` |
+| [`atoi`, `_atoi_l`, `_wtoi`, `_wtoi_l`](reference/atoi-atoi-l-wtoi-wtoi-l.md) | Convert character to integer value | `LC_NUMERIC` |
+| [`_atoi64`, `_atoi64_l`, `_wtoi64`, `_wtoi64_l`](reference/atoi64-atoi64-l-wtoi64-wtoi64-l.md) | Convert character to 64-bit integer value | `LC_NUMERIC` |
+| [`atol`, `_atol_l`, `_wtol`, `_wtol_l`](reference/atol-atol-l-wtol-wtol-l.md) | Convert character to long value | `LC_NUMERIC` |
+| [`_atodbl`, `_atodbl_l`, `_atoldbl`, `_atoldbl_l`, `_atoflt`, `_atoflt_l`](reference/atodbl-atodbl-l-atoldbl-atoldbl-l-atoflt-atoflt-l.md) | Convert character to double-long value | `LC_NUMERIC` |
+| [`is`, `isw` routines](is-isw-routines.md) | Test given integer for particular condition. | `LC_CTYPE` |
+| [`isleadbyte`, `_isleadbyte_l`](reference/isleadbyte-isleadbyte-l.md) | Test for lead byte | `LC_CTYPE` |
+| [`localeconv`](reference/localeconv.md) | Read appropriate values for formatting numeric quantities | `LC_MONETARY, LC_NUMERIC` |
+| [`MB_CUR_MAX`](mb-cur-max.md) | Maximum length in bytes of any multibyte character in current locale (macro defined in `STDLIB.H`) | `LC_CTYPE` |
+| [`_mbccpy`, `_mbccpy_l`](reference/mbccpy-mbccpy-l.md), [`_mbccpy_s`, `_mbccpy_s_l`](reference/mbccpy-s-mbccpy-s-l.md) | Copy one multibyte character | `LC_CTYPE` |
+| [`_mbclen`, `mblen`, `_mblen_l`](reference/mbclen-mblen-mblen-l.md) | Validate and return number of bytes in multibyte character | `LC_CTYPE` |
+| [`strlen`, `wcslen`, `_mbslen`, `_mbslen_l`, `_mbstrlen`, `_mbstrlen_l`](reference/strlen-wcslen-mbslen-mbslen-l-mbstrlen-mbstrlen-l.md) | For multibyte-character strings: validate each character in string; return string length | `LC_CTYPE` |
+| [`mbstowcs`, `_mbstowcs_l`](reference/mbstowcs-mbstowcs-l.md), [`mbstowcs_s`, `_mbstowcs_s_l`](reference/mbstowcs-s-mbstowcs-s-l.md) | Convert sequence of multibyte characters to corresponding sequence of wide characters | `LC_CTYPE` |
+| [`mbtowc`, `_mbtowc_l`](reference/mbtowc-mbtowc-l.md) | Convert multibyte character to corresponding wide character | `LC_CTYPE` |
+| [`printf`](reference/printf-printf-l-wprintf-wprintf-l.md) functions | Write formatted output | `LC_NUMERIC` (determines radix character output) |
+| [`scanf`](reference/scanf-scanf-l-wscanf-wscanf-l.md) functions | Read formatted input | `LC_NUMERIC` (determines radix character recognition) |
+| [`setlocale`, `_wsetlocale`](reference/setlocale-wsetlocale.md) | Select locale for program | Not applicable |
+| [`strcoll`, `wcscoll`, `_mbscoll`, `_strcoll_l`, `_wcscoll_l`, `_mbscoll_l`](reference/strcoll-wcscoll-mbscoll-strcoll-l-wcscoll-l-mbscoll-l.md) | Compare characters of two strings | `LC_COLLATE` |
+| [`_stricmp`, `_wcsicmp`, `_mbsicmp`, `_stricmp_l`, `_wcsicmp_l`, `_mbsicmp_l`](reference/stricmp-wcsicmp-mbsicmp-stricmp-l-wcsicmp-l-mbsicmp-l.md) | Compare two strings without regard to case | `LC_CTYPE` |
+| [`_stricoll`, `_wcsicoll`, `_mbsicoll`, `_stricoll_l`, `_wcsicoll_l`, `_mbsicoll_l`](reference/stricoll-wcsicoll-mbsicoll-stricoll-l-wcsicoll-l-mbsicoll-l.md) | Compare characters of two strings (case insensitive) | `LC_COLLATE` |
+| [`_strncoll`, `_wcsncoll`, `_mbsncoll`, `_strncoll_l`, `_wcsncoll_l`, `_mbsncoll_l`](reference/strncoll-wcsncoll-mbsncoll-strncoll-l-wcsncoll-l-mbsncoll-l.md) | Compare first **`n`** characters of two strings | `LC_COLLATE` |
+| [`_strnicmp`, `_wcsnicmp`, `_mbsnicmp`, `_strnicmp_l`, `_wcsnicmp_l`, `_mbsnicmp_l`](reference/strnicmp-wcsnicmp-mbsnicmp-strnicmp-l-wcsnicmp-l-mbsnicmp-l.md) | Compare characters of two strings without regard to case. | `LC_CTYPE` |
+| [`_strnicoll`, `_wcsnicoll`, `_mbsnicoll`, `_strnicoll_l`, `_wcsnicoll_l`, `_mbsnicoll_l`](reference/strnicoll-wcsnicoll-mbsnicoll-strnicoll-l-wcsnicoll-l-mbsnicoll-l.md) | Compare first **`n`** characters of two strings (case insensitive) | `LC_COLLATE` |
+| [`strftime`, `wcsftime`, `_strftime_l`, `_wcsftime_l`](reference/strftime-wcsftime-strftime-l-wcsftime-l.md) | Format date and time value according to supplied **`format`** argument | `LC_TIME` |
+| [`_strlwr`, `_wcslwr`, `_mbslwr`, `_strlwr_l`, `_wcslwr_l`, `_mbslwr_l`](reference/strlwr-wcslwr-mbslwr-strlwr-l-wcslwr-l-mbslwr-l.md), [`_strlwr_s`, `_strlwr_s_l`, `_mbslwr_s`, `_mbslwr_s_l`, `_wcslwr_s`, `_wcslwr_s_l`](reference/strlwr-s-strlwr-s-l-mbslwr-s-mbslwr-s-l-wcslwr-s-wcslwr-s-l.md) | Convert, in place, each uppercase letter in given string to lowercase | `LC_CTYPE` |
+| [`strtod`, `_strtod_l`, `wcstod`, `_wcstod_l`](reference/strtod-strtod-l-wcstod-wcstod-l.md) | Convert character string to **`double`** value | `LC_NUMERIC` (determines radix character recognition) |
+| [`strtol`, `wcstol`, `_strtol_l`, `_wcstol_l`](reference/strtol-wcstol-strtol-l-wcstol-l.md) | Convert character string to **`long`** value | `LC_NUMERIC` (determines radix character recognition) |
+| [`strtoul`, `_strtoul_l`, `wcstoul`, `_wcstoul_l`](reference/strtoul-strtoul-l-wcstoul-wcstoul-l.md) | Convert character string to unsigned long value | `LC_NUMERIC` (determines radix character recognition) |
+| [`_strupr`, `_strupr_l`, `_mbsupr`, `_mbsupr_l`, `_wcsupr_l`, `_wcsupr`](reference/strupr-strupr-l-mbsupr-mbsupr-l-wcsupr-l-wcsupr.md), [`_strupr_s`, `_strupr_s_l`, `_mbsupr_s`, `_mbsupr_s_l`, `_wcsupr_s`, `_wcsupr_s_l`](reference/strupr-s-strupr-s-l-mbsupr-s-mbsupr-s-l-wcsupr-s-wcsupr-s-l.md) | Convert, in place, each lowercase letter in string to uppercase | `LC_CTYPE` |
+| [`strxfrm`, `wcsxfrm`, `_strxfrm_l`, `_wcsxfrm_l`](reference/strxfrm-wcsxfrm-strxfrm-l-wcsxfrm-l.md) | Transform string into collated form according to locale | `LC_COLLATE` |
+| [`tolower`, `_tolower`, `towlower`, `_tolower_l`, `_towlower_l`](reference/tolower-tolower-towlower-tolower-l-towlower-l.md), [`_mbctolower`, `_mbctolower_l`, `_mbctoupper`, `_mbctoupper_l`](reference/mbctolower-mbctolower-l-mbctoupper-mbctoupper-l.md) | Convert given character to corresponding lowercase character | `LC_CTYPE` |
+| [`toupper`, `_toupper`, `towupper`, `_toupper_l`, `_towupper_l`](reference/toupper-toupper-towupper-toupper-l-towupper-l.md), [`_mbctolower`, `_mbctolower_l`, `_mbctoupper`, `_mbctoupper_l`](reference/mbctolower-mbctolower-l-mbctoupper-mbctoupper-l.md) | Convert given character to corresponding uppercase letter | `LC_CTYPE` |
+| [`wcstombs`, `_wcstombs_l`](reference/wcstombs-wcstombs-l.md), [`wcstombs_s`, `_wcstombs_s_l`](reference/wcstombs-s-wcstombs-s-l.md) | Convert sequence of wide characters to corresponding sequence of multibyte characters | `LC_CTYPE` |
+| [`wctomb`, `_wctomb_l`](reference/wctomb-wctomb-l.md), [`wctomb_s`, `_wctomb_s_l`](reference/wctomb-s-wctomb-s-l.md) | Convert wide character to corresponding multibyte character | `LC_CTYPE` |
> [!NOTE]
-> For multibyte routines, the multibyte code page must be equivalent to the locale set with [`setlocale`](./reference/setlocale-wsetlocale.md). [`_setmbcp`](./reference/setmbcp.md), with an argument of `_MB_CP_LOCALE` makes the multibyte code page the same as the **`setlocale`** code page.
+> For multibyte routines, the multibyte code page must be equivalent to the locale set with [`setlocale`](reference/setlocale-wsetlocale.md). [`_setmbcp`](reference/setmbcp.md), with an argument of `_MB_CP_LOCALE` makes the multibyte code page the same as the **`setlocale`** code page.
## See also
-[Internationalization](./internationalization.md)\
-[Universal C runtime routines by category](./run-time-routines-by-category.md)
+[Internationalization](internationalization.md)\
+[Universal C runtime routines by category](run-time-routines-by-category.md)
diff --git a/docs/c-runtime-library/lock.md b/docs/c-runtime-library/lock.md
index e9f4e94fa0..19562f13ef 100644
--- a/docs/c-runtime-library/lock.md
+++ b/docs/c-runtime-library/lock.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: _lock"
title: "_lock"
-ms.date: "11/04/2016"
+description: "Learn more about: _lock"
+ms.date: 11/04/2016
api_name: ["_lock"]
api_location: ["msvcr110_clr0400.dll", "msvcr120.dll", "msvcr100.dll", "msvcr90.dll", "msvcr80.dll", "msvcr110.dll", "msvcrt.dll", "msvcr120_clr0400.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_lock"]
helpviewer_keywords: ["lock function", "_lock function"]
-ms.assetid: 29f77c37-30de-4b3d-91b6-030216e645a6
---
# `_lock`
@@ -20,7 +19,7 @@ Acquires a multi-thread lock.
## Syntax
```cpp
-void __cdecl _lock
+void __cdecl _lock(
int locknum
);
```
diff --git a/docs/c-runtime-library/nolock-functions.md b/docs/c-runtime-library/nolock-functions.md
index 2f99d4430c..b231f2d923 100644
--- a/docs/c-runtime-library/nolock-functions.md
+++ b/docs/c-runtime-library/nolock-functions.md
@@ -1,53 +1,38 @@
---
-description: "Learn more about: _nolock Functions"
title: "_nolock Functions"
-ms.date: "11/04/2016"
+description: "Learn more about: _nolock Functions"
+ms.date: "04/14/2024"
helpviewer_keywords: ["_nolock functions", "nolock functions"]
-ms.assetid: 7d651d87-38d2-4303-9897-fdb5f7a3e899
---
# `_nolock` functions
-The `_nolock` functions are versions of I/O functions that don't perform any locking. They're provided for users requiring maximum performance. For more information, see [Multithreaded libraries performance](./multithreaded-libraries-performance.md).
+The `_nolock` functions are versions of I/O functions that don't perform any locking. They're provided for users requiring maximum performance. For more information, see [Multithreaded libraries performance](multithreaded-libraries-performance.md).
-Use _nolock functions only if your program is truly single-threaded or if it does its own locking.
+Use `_nolock` functions only if your program is truly single-threaded or if it does its own locking.
## No lock routines
-[`_fclose_nolock`](./reference/fclose-nolock.md)
-
-[`_fflush_nolock`](./reference/fflush-nolock.md)
-
-[`_fgetc_nolock`, `_fgetwc_nolock`](./reference/fgetc-nolock-fgetwc-nolock.md)
-
-[`_fread_nolock`](./reference/fread-nolock.md)
-
-[`_fseek_nolock`, `_fseeki64_nolock`](./reference/fseek-nolock-fseeki64-nolock.md)
-
-[`_ftell_nolock`, `_ftelli64_nolock`](./reference/ftell-nolock-ftelli64-nolock.md)
-
-[`_fwrite_nolock`](./reference/fwrite-nolock.md)
-
-[`_getc_nolock`, `_getwc_nolock`](./reference/getc-nolock-getwc-nolock.md)
-
-[`_getch_nolock`, `_getwch_nolock`](./reference/getch-nolock-getwch-nolock.md)
-
-[`_getchar_nolock`, `_getwchar_nolock`](./reference/getchar-nolock-getwchar-nolock.md)
-
-[`_getche_nolock`, `_getwche_nolock`](./reference/getche-nolock-getwche-nolock.md)
-
-[`_getdcwd_nolock`, `_wgetdcwd_nolock`](./reference/getdcwd-nolock-wgetdcwd-nolock.md)
-
-[`_putc_nolock`, `_putwc_nolock`](./reference/putc-nolock-putwc-nolock.md)
-
-[`_putch_nolock`, `_putwch_nolock`](./reference/putch-nolock-putwch-nolock.md)
-
-[`_putchar_nolock`, `_putwchar_nolock`](./reference/putchar-nolock-putwchar-nolock.md)
-
-[`_ungetc_nolock`, `_ungetwc_nolock`](./reference/ungetc-nolock-ungetwc-nolock.md)
-
-[`_ungetch_nolock`, `_ungetwch_nolock`](./reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md)
+| Routine | Use |
+|---|---|
+| [`_fclose_nolock`](reference/fclose-nolock.md) | Closes a stream without locking |
+| [`_fflush_nolock`](reference/fflush-nolock.md) | Flushes a stream without locking |
+| [`_fgetc_nolock`, `_fgetwc_nolock`](reference/fgetc-nolock-fgetwc-nolock.md) | Reads a character from a stream without locking |
+| [`_fread_nolock`](reference/fread-nolock.md) | Reads data from a stream without locking |
+| [`_fseek_nolock`, `_fseeki64_nolock`](reference/fseek-nolock-fseeki64-nolock.md) | Moves the file pointer to a specified location without locking |
+| [`_ftell_nolock`, `_ftelli64_nolock`](reference/ftell-nolock-ftelli64-nolock.md) | Gets the current position of a file pointer without locking |
+| [`_fwrite_nolock`](reference/fwrite-nolock.md) | Writes data to a stream without locking |
+| [`_getc_nolock`, `_getwc_nolock`](reference/getc-nolock-getwc-nolock.md) | Reads a character from a stream without locking |
+| [`_getch_nolock`, `_getwch_nolock`](reference/getch-nolock-getwch-nolock.md) | Gets a character from the console without echo and without locking |
+| [`_getchar_nolock`, `_getwchar_nolock`](reference/getchar-nolock-getwchar-nolock.md) | Reads a character from the standard input without locking |
+| [`_getche_nolock`, `_getwche_nolock`](reference/getche-nolock-getwche-nolock.md) | Gets a character from the console with echo and without locking |
+| [`_getdcwd_nolock`, `_wgetdcwd_nolock`](reference/getdcwd-nolock-wgetdcwd-nolock.md) | Gets the full path of the current working directory on the specified drive |
+| [`_putc_nolock`, `_putwc_nolock`](reference/putc-nolock-putwc-nolock.md) | Writes a character to a stream without locking |
+| [`_putch_nolock`, `_putwch_nolock`](reference/putch-nolock-putwch-nolock.md) | Writes a character to the console without locking |
+| [`_putchar_nolock`, `_putwchar_nolock`](reference/putchar-nolock-putwchar-nolock.md) | Writes a character to `stdout` without locking |
+| [`_ungetc_nolock`, `_ungetwc_nolock`](reference/ungetc-nolock-ungetwc-nolock.md) | Pushes a character back onto the stream without locking |
+| [`_ungetch_nolock`, `_ungetwch_nolock`](reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md) | Pushes back the last character that's read from the console without locking |
## See also
-[Input and output](./input-and-output.md)\
-[Universal C runtime routines by category](./run-time-routines-by-category.md)
+[Input and output](input-and-output.md)\
+[Universal C runtime routines by category](run-time-routines-by-category.md)
diff --git a/docs/c-runtime-library/reference/abort.md b/docs/c-runtime-library/reference/abort.md
index 991f464049..436a39de91 100644
--- a/docs/c-runtime-library/reference/abort.md
+++ b/docs/c-runtime-library/reference/abort.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: abort"
title: "abort"
+description: "Learn more about: abort"
ms.date: 07/07/2022
api_name: ["abort", "_o_abort"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-runtime-l1-1-0.dll"]
@@ -14,7 +14,7 @@ helpviewer_keywords: ["aborting current process", "abort function", "processes,
Aborts the current process and returns an error code.
> [!NOTE]
-> Do not use this method to shut down a Microsoft Store app or Universal Windows Platform (UWP) app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/legal/windows/agreements/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
+> Do not use this method to shut down a Microsoft Store app or Universal Windows Platform (UWP) app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/windows/apps/publish/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
## Syntax
@@ -71,8 +71,8 @@ The following program tries to open a file and aborts if the attempt fails.
// the abort function by attempting to open a file
// and aborts if the attempt fails.
-#include
-#include
+#include
+#include
int main( void )
{
diff --git a/docs/c-runtime-library/reference/access-s-waccess-s.md b/docs/c-runtime-library/reference/access-s-waccess-s.md
index 1f3fedc12e..c054b3b97d 100644
--- a/docs/c-runtime-library/reference/access-s-waccess-s.md
+++ b/docs/c-runtime-library/reference/access-s-waccess-s.md
@@ -1,19 +1,20 @@
---
-description: "Learn more about: _access_s, _waccess_s"
-title: "_access_s, _waccess_s"
+description: "Learn more about: _access_s, _waccess_s, _taccess_s"
+title: "_access_s, _waccess_s, _taccess_s"
ms.date: "4/2/2020"
-api_name: ["_access_s", "_waccess_s", "_o__access_s", "_o__waccess_s"]
+api_name: ["_access_s", "_waccess_s", "_taccess_s", "_o__access_s", "_o__waccess_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-filesystem-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["waccess_s", "access_s", "_waccess_s", "_access_s"]
-helpviewer_keywords: ["access_s function", "taccess_s function", "_taccess_s function", "waccess_s function", "_access_s function", "_waccess_s function"]
-ms.assetid: fb3004fc-dcd3-4569-8b27-d817546e947e
+f1_keywords: ["waccess_s", "access_s", "_taccess_s"]
+helpviewer_keywords: ["access_s function", "waccess_s function", "_taccess_s function"]
---
-# `_access_s`, `_waccess_s`
+# `_access_s`, `_waccess_s`, `_taccess_s`
Determines file read/write permissions. These functions are versions of [`_access`, `_waccess`](access-waccess.md) with security enhancements as described in [Security features in the CRT](../security-features-in-the-crt.md).
+For `_taccess_s`, see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -66,18 +67,20 @@ These functions validate their parameters. If *`path`* is `NULL` or *`mode`* doe
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| Tchar.h routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` function | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
-| `_taccess_s` | **`_access_s`** | **`_access_s`** | **`_waccess_s`** |
+| `_taccess_s` | `_access_s` | `_access_s` | `_waccess_s` |
## Requirements
| Routine | Required header | Optional header |
|---|---|---|
-| **`_access_s`** | \ | \ |
-| **`_waccess_s`** | \ or \ | \ |
+| **`_access_s`** | `` | `` |
+| **`_waccess_s`** | `` or `` | `` |
## Example
diff --git a/docs/c-runtime-library/reference/access-waccess.md b/docs/c-runtime-library/reference/access-waccess.md
index b6c08cc8bf..87cf212ca0 100644
--- a/docs/c-runtime-library/reference/access-waccess.md
+++ b/docs/c-runtime-library/reference/access-waccess.md
@@ -1,19 +1,20 @@
---
-description: "Learn more about: _access, _waccess"
title: "_access, _waccess"
+description: "Learn more about: _access, _waccess"
ms.date: "4/2/2020"
-api_name: ["_access", "_waccess", "_o__access", "_o__waccess"]
+api_name: ["_access", "_waccess", "t_access", "_o__access", "_o__waccess"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-filesystem-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_waccess", "_access", "taccess", "waccess", "_taccess"]
helpviewer_keywords: ["access function", "_taccess function", "waccess function", "_access function", "_waccess function", "taccess function"]
-ms.assetid: ba34f745-85c3-49e5-a7d4-3590bd249dd3
---
-# `_access`, `_waccess`
+# `_access`, `_waccess`, `t_access`
Determines if a file is read-only or not. More secure versions are available; see [`_access_s`, `_waccess_s`](access-s-waccess-s.md).
+For `_taccess`, see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -66,7 +67,7 @@ This function validates its parameters. If *`path`* is `NULL` or *`mode`* doesn'
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
-### Generic-text routine mappings
+### Generic-text function mappings
| `Tchar.h` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
@@ -89,9 +90,9 @@ The following example uses **`_access`** to check the file named *`crt_ACCESS.C`
// This example uses _access to check the file named
// crt_ACCESS.C to see if it exists and if writing is allowed.
-#include
-#include
-#include
+#include
+#include
+#include
int main( void )
{
diff --git a/docs/c-runtime-library/reference/and.md b/docs/c-runtime-library/reference/and.md
index 2a5a4412c1..efa2cca286 100644
--- a/docs/c-runtime-library/reference/and.md
+++ b/docs/c-runtime-library/reference/and.md
@@ -1,13 +1,12 @@
---
-description: "Learn more about: and"
title: "and"
+description: "Learn more about: and"
ms.date: "11/04/2016"
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["ISO646/and", "and", "std.and", "std::and"]
helpviewer_keywords: ["and macro"]
-ms.assetid: 2644ab57-8e1b-48f0-9021-cafe3e26bdc4
---
# `and`
@@ -16,7 +15,6 @@ An alternative to the && operator.
## Syntax
```C
-
#define and &&
```
diff --git a/docs/c-runtime-library/reference/assert-asserte-assert-expr-macros.md b/docs/c-runtime-library/reference/assert-asserte-assert-expr-macros.md
index c3029df584..d2d7395810 100644
--- a/docs/c-runtime-library/reference/assert-asserte-assert-expr-macros.md
+++ b/docs/c-runtime-library/reference/assert-asserte-assert-expr-macros.md
@@ -42,7 +42,7 @@ Because the `_ASSERTE` macro specifies the failed expression, and `_ASSERT_EXPR`
Unless you specify otherwise with the [`_CrtSetReportMode`](crtsetreportmode.md) and [`_CrtSetReportFile`](crtsetreportfile.md) functions, messages appear in a pop-up dialog box equivalent to setting:
```C
-_CrtSetReportMode(CRT_ASSERT, _CRTDBG_MODE_WNDW);
+_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_WNDW);
```
`_CrtDbgReportW` generates the debug report and determines its destination or destinations, based on the current report mode or modes and file defined for the `_CRT_ASSERT` report type. By default, assertion failures and errors are directed to a debug message window. The [`_CrtSetReportMode`](crtsetreportmode.md) and [`_CrtSetReportFile`](crtsetreportfile.md) functions are used to define the destinations for each report type.
diff --git a/docs/c-runtime-library/reference/atanh-atanhf-atanhl.md b/docs/c-runtime-library/reference/atanh-atanhf-atanhl.md
index 02b797f39a..b7ce5af41b 100644
--- a/docs/c-runtime-library/reference/atanh-atanhf-atanhl.md
+++ b/docs/c-runtime-library/reference/atanh-atanhf-atanhl.md
@@ -1,14 +1,13 @@
---
title: "atanh, atanhf, atanhl"
description: "API reference for atanh, atanhf, and atanhl; which calculate the inverse hyperbolic tangent of a floating-point value."
-ms.date: "08/31/2020"
+ms.date: 08/31/2020
api_name: ["atanhl", "atanhf", "atanh", "_o_atanh", "_o_atanhf", "_o_atanhl"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-math-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["atanhl", "atanhf", "atanh"]
-helpviewer_keywords: ["atanhf function", "atanhl function", "atanh funciton"]
-ms.assetid: 83a43b5b-2580-4461-854f-dc84236d9f32
+helpviewer_keywords: ["atanhf function", "atanhl function", "atanh function"]
---
# `atanh`, `atanhf`, `atanhl`
diff --git a/docs/c-runtime-library/reference/atoi-atoi-l-wtoi-wtoi-l.md b/docs/c-runtime-library/reference/atoi-atoi-l-wtoi-wtoi-l.md
index 917b291e28..4101aad9e3 100644
--- a/docs/c-runtime-library/reference/atoi-atoi-l-wtoi-wtoi-l.md
+++ b/docs/c-runtime-library/reference/atoi-atoi-l-wtoi-wtoi-l.md
@@ -53,7 +53,7 @@ These functions convert a character string to an integer value (**`atoi`** and *
The *`str`* argument to **`atoi`** and **`_wtoi`** has the following form:
-> [*`whitespace`*] [*`sign`*] [*`digits`*]]
+> [*`whitespace`*] [*`sign`*] [*`digits`*]
A *`whitespace`* consists of space or tab characters, which are ignored; *`sign`* is either plus (+) or minus (-); and *`digits`* are one or more digits.
diff --git a/docs/c-runtime-library/reference/atol-atol-l-wtol-wtol-l.md b/docs/c-runtime-library/reference/atol-atol-l-wtol-wtol-l.md
index bb6f755930..f724d15eaa 100644
--- a/docs/c-runtime-library/reference/atol-atol-l-wtol-wtol-l.md
+++ b/docs/c-runtime-library/reference/atol-atol-l-wtol-wtol-l.md
@@ -54,7 +54,7 @@ The input string is a sequence of characters that can be interpreted as a numeri
The *`str`* argument to **`atol`** has the following form:
-> [*`whitespace`*] [*`sign`*] [*`digits`*]]
+> [*`whitespace`*] [*`sign`*] [*`digits`*]
A *`whitespace`* consists of space or tab characters, which are ignored; *`sign`* is either plus (`+`) or minus (`-`); and *`digits`* are one or more digits.
diff --git a/docs/c-runtime-library/reference/bitand.md b/docs/c-runtime-library/reference/bitand.md
index cc4b84b0bd..0701824a21 100644
--- a/docs/c-runtime-library/reference/bitand.md
+++ b/docs/c-runtime-library/reference/bitand.md
@@ -1,13 +1,12 @@
---
-description: "Learn more about: bitand"
title: "bitand"
+description: "Learn more about: bitand"
ms.date: "11/04/2016"
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["std::bitand", "std.bitand", "ISO646/bitand", "bitand"]
helpviewer_keywords: ["bitand function"]
-ms.assetid: 279cf9b5-fac1-49de-b329-f1a31b3481fe
---
# `bitand`
@@ -16,7 +15,6 @@ An alternative to the & operator.
## Syntax
```C
-
#define bitand &
```
diff --git a/docs/c-runtime-library/reference/bitor.md b/docs/c-runtime-library/reference/bitor.md
index 4451365a0e..8f2aaf236d 100644
--- a/docs/c-runtime-library/reference/bitor.md
+++ b/docs/c-runtime-library/reference/bitor.md
@@ -1,13 +1,12 @@
---
-description: "Learn more about: bitor"
title: "bitor"
+description: "Learn more about: bitor"
ms.date: "11/04/2016"
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["ISO646/bitor", "bitor", "std.bitor", "std::bitor"]
helpviewer_keywords: ["bitor function"]
-ms.assetid: 3c0a3711-9c74-41f2-b400-2f7797da30d1
---
# `bitor`
@@ -16,7 +15,6 @@ An alternative to the `|` operator.
## Syntax
```C
-
#define bitor |
```
diff --git a/docs/c-runtime-library/reference/byteswap-uint64-byteswap-ulong-byteswap-ushort.md b/docs/c-runtime-library/reference/byteswap-uint64-byteswap-ulong-byteswap-ushort.md
index 5c63829355..88af49e8eb 100644
--- a/docs/c-runtime-library/reference/byteswap-uint64-byteswap-ulong-byteswap-ushort.md
+++ b/docs/c-runtime-library/reference/byteswap-uint64-byteswap-ulong-byteswap-ushort.md
@@ -54,8 +54,8 @@ int main()
```
```Output
-byteswap of 102030405060708 = 807060504030201
-byteswap of 1020304 = 4030201
+byteswap of 0102030405060708 = 0807060504030201
+byteswap of 01020304 = 04030201
```
## See also
diff --git a/docs/c-runtime-library/reference/calloc-dbg.md b/docs/c-runtime-library/reference/calloc-dbg.md
index 0c3df65724..fbff456b61 100644
--- a/docs/c-runtime-library/reference/calloc-dbg.md
+++ b/docs/c-runtime-library/reference/calloc-dbg.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _calloc_dbg"
title: "_calloc_dbg"
+description: "Learn more about: _calloc_dbg"
ms.date: "11/04/2016"
api_name: ["_calloc_dbg"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_calloc_dbg", "calloc_dbg"]
helpviewer_keywords: ["_calloc_dbg function", "calloc_dbg function"]
-ms.assetid: 7f62c42b-eb9f-4de5-87d0-df57036c87de
---
# `_calloc_dbg`
@@ -37,7 +36,7 @@ Requested size of each memory block (bytes).
*`blockType`*\
Requested type of memory block: `_CLIENT_BLOCK` or `_NORMAL_BLOCK`.
-For information about the allocation block types and how they're used, see[Types of blocks on the debug heap](../crt-debug-heap-details.md#types-of-blocks-on-the-debug-heap).
+For information about the allocation block types and how they're used, see [Types of blocks on the debug heap](../crt-debug-heap-details.md#types-of-blocks-on-the-debug-heap).
*`filename`*\
Pointer to name of the source file that requested allocation operation or `NULL`.
@@ -100,7 +99,7 @@ int main( void )
else
printf( "Problem allocating memory\n" );
- / _free_dbg must be called to free CLIENT type blocks
+ // _free_dbg must be called to free CLIENT type blocks
free( bufferN );
_free_dbg( bufferC, _CLIENT_BLOCK );
}
diff --git a/docs/c-runtime-library/reference/calloc.md b/docs/c-runtime-library/reference/calloc.md
index 94c5d3265b..eda1a8195f 100644
--- a/docs/c-runtime-library/reference/calloc.md
+++ b/docs/c-runtime-library/reference/calloc.md
@@ -96,4 +96,4 @@ Allocated 40 long integers
[Memory allocation](../memory-allocation.md)\
[`free`](free.md)\
[`malloc`](malloc.md)\
-[`realloc`](realloc.md)\
+[`realloc`](realloc.md)
diff --git a/docs/c-runtime-library/reference/cgets-s-cgetws-s.md b/docs/c-runtime-library/reference/cgets-s-cgetws-s.md
index 8709404d4c..82de69ea28 100644
--- a/docs/c-runtime-library/reference/cgets-s-cgetws-s.md
+++ b/docs/c-runtime-library/reference/cgets-s-cgetws-s.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _cgets_s, _cgetws_s"
title: "_cgets_s, _cgetws_s"
+description: "Learn more about: _cgets_s, _cgetws_s"
ms.date: "4/2/2020"
api_name: ["_cgetws_s", "_cgets_s", "_o__cgets_s", "_o__cgetws_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-conio-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_cgets_s", "cgets_s", "cgetws_s", "_cgetws_s"]
helpviewer_keywords: ["strings [C++], getting from console", "console, getting strings from", "_cgets_s function", "cget_s function", "_cgetws_s function", "cgetws_s function"]
-ms.assetid: 38b74897-afe6-4dd9-a43f-36a3c0d72c5c
---
# `_cgets_s`, `_cgetws_s`
@@ -26,7 +25,7 @@ errno_t _cgets_s(
size_t *pSizeRead
);
errno_t _cgetws_s(
- wchar_t *buffer
+ wchar_t *buffer,
size_t numberOfElements,
size_t *pSizeRead
);
diff --git a/docs/c-runtime-library/reference/chdir-wchdir.md b/docs/c-runtime-library/reference/chdir-wchdir.md
index 1ceeb72ce8..d95f085350 100644
--- a/docs/c-runtime-library/reference/chdir-wchdir.md
+++ b/docs/c-runtime-library/reference/chdir-wchdir.md
@@ -78,7 +78,6 @@ For more compatibility information, see [Compatibility](../compatibility.md).
int main( int argc, char *argv[] )
{
-
if(_chdir( argv[1] ) )
{
switch (errno)
diff --git a/docs/c-runtime-library/reference/chmod-wchmod.md b/docs/c-runtime-library/reference/chmod-wchmod.md
index 327b83aee7..eb98e7289c 100644
--- a/docs/c-runtime-library/reference/chmod-wchmod.md
+++ b/docs/c-runtime-library/reference/chmod-wchmod.md
@@ -114,7 +114,6 @@ void set_mode_and_report(char * filename, int mask)
int main( void )
{
-
// Create or append to a file.
system( "echo /* End of file */ >> crt_chmod.c_input" );
diff --git a/docs/c-runtime-library/reference/controlfp-s.md b/docs/c-runtime-library/reference/controlfp-s.md
index d955dfb42e..8de3df8b7c 100644
--- a/docs/c-runtime-library/reference/controlfp-s.md
+++ b/docs/c-runtime-library/reference/controlfp-s.md
@@ -1,7 +1,7 @@
---
description: "Learn more about: _controlfp_s"
title: "_controlfp_s"
-ms.date: "4/2/2020"
+ms.date: 03/27/2025
api_name: ["_controlfp_s", "_o__controlfp_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-runtime-l1-1-0.dll"]
api_type: ["DLLExport"]
@@ -75,16 +75,23 @@ _controlfp_s(¤t_word, _DN_FLUSH, _MCW_DN);
// and x64 processors with SSE2 support. Ignored on other x86 platforms.
```
-On ARM platforms, the **`_controlfp_s`** function applies to the FPSCR register. On x64 architectures, only the SSE2 control word that's stored in the MXCSR register is affected. On Intel (x86) platforms, **`_controlfp_s`** affects the control words for both the x87 and the SSE2, if present. It's possible for the two control words to be inconsistent with each other (because of a previous call to [`__control87_2`](control87-controlfp-control87-2.md), for example); if there's an inconsistency between the two control words, **`_controlfp_s`** sets the `EM_AMBIGUOUS` flag in *`currentControl`*. It's a warning that the returned control word might not represent the state of both floating-point control words accurately.
+This function is ignored when you use [`/clr` (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md) to compile because the common language runtime (CLR) only supports the default floating-point precision.
-On the ARM and x64 architectures, changing the infinity mode or the floating-point precision isn't supported. If the precision control mask is used on the x64 platform, the function raises an assertion and the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md).
+On x64, only the SSE2 control word stored in the MXCSR register is affected. Changing the infinity mode or the floating-point precision isn't supported. If the precision control mask is used on the x64 platform, the function raises an assertion and the invalid parameter handler is invoked as described in [Parameter validation](../parameter-validation.md).
-If the mask isn't set correctly, this function generates an invalid parameter exception, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, this function returns `EINVAL` and sets `errno` to `EINVAL`.
+On x86, **`_controlfp_s`** affects the control words for both the x87 and the SSE2, if present. It's possible for the two control words to be inconsistent with each other (because of a previous call to [`__control87_2`](control87-controlfp-control87-2.md), for example); if there's an inconsistency between the two control words, **`_controlfp_s`** sets the `EM_AMBIGUOUS` flag in *`currentControl`*. It's a warning that the returned control word might not represent the state of both floating-point control words accurately.
-This function is ignored when you use [`/clr` (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md) to compile because the common language runtime (CLR) only supports the default floating-point precision.
+If the mask isn't set correctly, this function generates an invalid parameter exception, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, this function returns `EINVAL` and sets `errno` to `EINVAL`.
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
+### Arm platforms
+
+- Changing the infinity mode or the floating-point precision isn't supported. If the precision control mask is used on the x64 platform, the function raises an assertion and the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md).
+- On ARM32 (discontinued), Windows doesn't support FP exceptions.
+- On ARM64, unmasking the whole `_MCW_EM` or any bits from it (`_EM_INEXACT`, `_EM_UNDERFLOW`, `_EM_OVERFLOW`, `_EM_ZERODIVIDE`, and `_EM_INVALID`) correctly change the FPCR register. Floating point exceptions raised by standard math functions, like Invalid operation from `std::acos`, are exempt from this behavior and can be ignored or raised properly depending on the FPCR register. For more information, see [Overview of ARM32 ABI Conventions](../../build/overview-of-arm-abi-conventions.md#floating-point-exceptions).
+- On ARM64EC, Windows catches processor floating-point exceptions and disables them in the FPCR register. This ensures consistent behavior across different processor variants.
+
### Mask constants and values
For the `_MCW_EM` mask, clearing it sets the exception, which allows the hardware exception; setting it hides the exception. If a `_EM_UNDERFLOW` or `_EM_OVERFLOW` occurs, no hardware exception is thrown until the next floating-point instruction is executed. To generate a hardware exception immediately after `_EM_UNDERFLOW` or `_EM_OVERFLOW`, call the `FWAIT MASM` instruction.
diff --git a/docs/c-runtime-library/reference/cputs-cputws.md b/docs/c-runtime-library/reference/cputs-cputws.md
index cf01b13749..5ffe5fe412 100644
--- a/docs/c-runtime-library/reference/cputs-cputws.md
+++ b/docs/c-runtime-library/reference/cputs-cputws.md
@@ -106,7 +106,6 @@ void wprint_to_console(wchar_t* wbuffer)
int main()
{
-
// String to print at console.
// Notice the \r (return) character.
char* buffer = "Hello world (courtesy of _cputs)!\r\n";
diff --git a/docs/c-runtime-library/reference/crtcheckmemory.md b/docs/c-runtime-library/reference/crtcheckmemory.md
index de0f6e98ce..5c9ca5d58e 100644
--- a/docs/c-runtime-library/reference/crtcheckmemory.md
+++ b/docs/c-runtime-library/reference/crtcheckmemory.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _CrtCheckMemory"
title: "_CrtCheckMemory"
+description: "Learn more about: _CrtCheckMemory"
ms.date: "11/04/2016"
api_name: ["_CrtCheckMemory"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CrtCheckMemory", "_CrtCheckMemory"]
helpviewer_keywords: ["_CrtCheckMemory function", "CrtCheckMemory function"]
-ms.assetid: 457cc72e-60fd-4177-ab5c-6ae26a420765
---
# `_CrtCheckMemory`
@@ -17,7 +16,6 @@ Confirms the integrity of the memory blocks allocated in the debug heap (debug v
## Syntax
```C
-
int _CrtCheckMemory( void );
```
diff --git a/docs/c-runtime-library/reference/crtdumpmemoryleaks.md b/docs/c-runtime-library/reference/crtdumpmemoryleaks.md
index 5e934bfd26..28291b7a9c 100644
--- a/docs/c-runtime-library/reference/crtdumpmemoryleaks.md
+++ b/docs/c-runtime-library/reference/crtdumpmemoryleaks.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _CrtDumpMemoryLeaks"
title: "_CrtDumpMemoryLeaks"
+description: "Learn more about: _CrtDumpMemoryLeaks"
ms.date: "11/04/2016"
api_name: ["_CrtDumpMemoryLeaks"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -16,7 +16,6 @@ Dumps all the memory blocks in the debug heap when a memory leak has occurred (d
## Syntax
```C
-
int _CrtDumpMemoryLeaks( void );
```
diff --git a/docs/c-runtime-library/reference/crtmemdifference.md b/docs/c-runtime-library/reference/crtmemdifference.md
index f04c412996..2424df0b3f 100644
--- a/docs/c-runtime-library/reference/crtmemdifference.md
+++ b/docs/c-runtime-library/reference/crtmemdifference.md
@@ -63,4 +63,4 @@ For more compatibility information, see [Compatibility](../compatibility.md).
## See also
[Debug routines](../debug-routines.md)\
-[`_crtDbgFlag`](../crtdbgflag.md)\
+[`_crtDbgFlag`](../crtdbgflag.md)
diff --git a/docs/c-runtime-library/reference/crtmemdumpstatistics.md b/docs/c-runtime-library/reference/crtmemdumpstatistics.md
index d9de27b674..8c41b648eb 100644
--- a/docs/c-runtime-library/reference/crtmemdumpstatistics.md
+++ b/docs/c-runtime-library/reference/crtmemdumpstatistics.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _CrtMemDumpStatistics"
title: "_CrtMemDumpStatistics"
+description: "Learn more about: _CrtMemDumpStatistics"
ms.date: "11/04/2016"
api_name: ["_CrtMemDumpStatistics"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CrtMemDumpStatistics", "_CrtMemDumpStatistics"]
helpviewer_keywords: ["_CrtMemDumpStatistics function", "CrtMemDumpStatistics function"]
-ms.assetid: 27b9d731-3184-4a2d-b9a7-6566ab28a9fe
---
# `_CrtMemDumpStatistics`
@@ -47,4 +46,4 @@ For more compatibility information, see [Compatibility](../compatibility.md).
## See also
-[Debug routines](../debug-routines.md)\
+[Debug routines](../debug-routines.md)
diff --git a/docs/c-runtime-library/reference/crtreportblocktype.md b/docs/c-runtime-library/reference/crtreportblocktype.md
index 48220ad606..e9c58f7c24 100644
--- a/docs/c-runtime-library/reference/crtreportblocktype.md
+++ b/docs/c-runtime-library/reference/crtreportblocktype.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: _CrtReportBlockType"
title: "_CrtReportBlockType"
-ms.date: "11/04/2016"
+description: "Learn more about: _CrtReportBlockType"
+ms.date: 11/04/2016
api_name: ["_CrtReportBlockType"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_CrtReportBlockType", "CrtReportBlockType"]
helpviewer_keywords: ["CrtReportBlockType function", "BLOCK_SUBTYPE macro", "_CrtReportBlockType function", "_BLOCK_TYPE macro", "_BLOCK_SUBTYPE macro", "BLOCK_TYPE macro"]
-ms.assetid: 0f4b9da7-bebb-4956-9541-b2581640ec6b
---
# `_CrtReportBlockType`
@@ -19,7 +18,7 @@ Returns the block type/subtype associated with a given debug heap block pointer.
```C
int _CrtReportBlockType(
const void * pBlock
-};
+);
```
### Parameters
diff --git a/docs/c-runtime-library/reference/crtsetbreakalloc.md b/docs/c-runtime-library/reference/crtsetbreakalloc.md
index cb64fc42fc..dba54054c4 100644
--- a/docs/c-runtime-library/reference/crtsetbreakalloc.md
+++ b/docs/c-runtime-library/reference/crtsetbreakalloc.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _CrtSetBreakAlloc"
title: "_CrtSetBreakAlloc"
+description: "Learn more about: _CrtSetBreakAlloc"
ms.date: "11/04/2016"
api_name: ["_CrtSetBreakAlloc"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CrtSetBreakAlloc", "_CrtSetBreakAlloc"]
helpviewer_keywords: ["CrtSetBreakAlloc function", "_CrtSetBreakAlloc function"]
-ms.assetid: 33bfc6af-a9ea-405b-a29f-1c2d4d9880a1
---
# `_CrtSetBreakAlloc`
@@ -99,4 +98,4 @@ int main( )
## See also
-[Debug routines](../debug-routines.md)\
+[Debug routines](../debug-routines.md)
diff --git a/docs/c-runtime-library/reference/crtsetdebugfillthreshold.md b/docs/c-runtime-library/reference/crtsetdebugfillthreshold.md
index bd91d7fa57..b7ce8b7bbb 100644
--- a/docs/c-runtime-library/reference/crtsetdebugfillthreshold.md
+++ b/docs/c-runtime-library/reference/crtsetdebugfillthreshold.md
@@ -1,14 +1,13 @@
---
title: "_CrtSetDebugFillThreshold"
description: "Use the _CrtSetDebugFillThreshold function to set the maximum amount of buffer to fill in secure CRT functions."
-ms.date: "10/31/2019"
+ms.date: 04/10/2025
api_name: ["_CrtSetDebugFillThreshold"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_CrtSetDebugFillThreshold", "CrtSetDebugFillThreshold"]
helpviewer_keywords: ["debug, buffer-filling behavior", "CrtSetDebugFillThreshold function", "_CrtSetDebugFillThreshold function", "buffer-filling behavior", "0xFE"]
-ms.assetid: 6cb360e8-56ae-4248-b17f-e28aee3e0ed7
---
# `_CrtSetDebugFillThreshold`
@@ -38,58 +37,36 @@ The default threshold is `SIZE_T_MAX`.
Here's a list of the affected functions:
- [`asctime_s`, `_wasctime_s`](asctime-s-wasctime-s.md)
-
- [`_cgets_s`, `_cgetws_s`](cgets-s-cgetws-s.md)
-
- [`ctime_s`, `_ctime32_s`, `_ctime64_s`, `_wctime_s`, `_wctime32_s`, `_wctime64_s`](ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md)
-
- [`_ecvt_s`](ecvt-s.md)
-
- [`_fcvt_s`](fcvt-s.md)
-
- [`_gcvt_s`](gcvt-s.md)
-
- [`_itoa_s`, `_ltoa_s`, `_ultoa_s`, `_i64toa_s`, `_ui64toa_s`, `_itow_s`, `_ltow_s`, `_ultow_s`, `_i64tow_s`, `_ui64tow_s`](itoa-s-itow-s.md)
-
- [`_makepath_s`, `_wmakepath_s`](makepath-s-wmakepath-s.md)
-
- [`_mbsnbcat_s`, `_mbsnbcat_s_l`](mbsnbcat-s-mbsnbcat-s-l.md)
-
- [`_mbsnbcpy_s`, `_mbsnbcpy_s_l`](mbsnbcpy-s-mbsnbcpy-s-l.md)
-
- [`_mbsnbset_s`, `_mbsnbset_s_l`](mbsnbset-s-mbsnbset-s-l.md)
-
- [`_mktemp_s`, `_wmktemp_s`](makepath-s-wmakepath-s.md)
-
- [`_splitpath_s`, `_wsplitpath_s`](splitpath-s-wsplitpath-s.md)
-
- [`strcat_s`, `wcscat_s`, `_mbscat_s`](strcat-s-wcscat-s-mbscat-s.md)
-
- [`strcpy_s`, `wcscpy_s`, `_mbscpy_s`](strcpy-s-wcscpy-s-mbscpy-s.md)
-
- [`_strdate_s`, `_wstrdate_s`](strdate-s-wstrdate-s.md)
-
- [`strerror_s`, `_strerror_s`, `_wcserror_s`, `__wcserror_s`](strerror-s-strerror-s-wcserror-s-wcserror-s.md)
-
- [`_strlwr_s`, `_strlwr_s_l`, `_mbslwr_s`, `_mbslwr_s_l`, `_wcslwr_s`, `_wcslwr_s_l`](strlwr-s-strlwr-s-l-mbslwr-s-mbslwr-s-l-wcslwr-s-wcslwr-s-l.md)
-
- [`strncat_s`, `_strncat_s_l`, `wcsncat_s`, `_wcsncat_s_l`, `_mbsncat_s`, `_mbsncat_s_l`](strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md)
-
- [`strncpy_s`, `_strncpy_s_l`, `wcsncpy_s`, `_wcsncpy_s_l`, `_mbsncpy_s`, `_mbsncpy_s_l`](strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md)
-
- [`_strnset_s`, `_strnset_s_l`, `_wcsnset_s`, `_wcsnset_s_l`, `_mbsnset_s`, `_mbsnset_s_l`](strnset-s-strnset-s-l-wcsnset-s-wcsnset-s-l-mbsnset-s-mbsnset-s-l.md)
-
- [`_strset_s`, `_strset_s_l`, `_wcsset_s`, `_wcsset_s_l`, `_mbsset_s`, `_mbsset_s_l`](strset-s-strset-s-l-wcsset-s-wcsset-s-l-mbsset-s-mbsset-s-l.md)
-
- [`_strtime_s`, `_wstrtime_s`](strtime-s-wstrtime-s.md)
-
- [`_strupr_s`, `_strupr_s_l`, `_mbsupr_s`, `_mbsupr_s_l`, `_wcsupr_s`, `_wcsupr_s_l`](strupr-s-strupr-s-l-mbsupr-s-mbsupr-s-l-wcsupr-s-wcsupr-s-l.md)
-
+- [`vsnprintf_s`, `_vsnprintf_s`, `_vsnprintf_s_l`, `_vsnwprintf_s`, _vsnwpr`intf_s_l](vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l.md)
+
## Requirements
| Routine | Required header |
|---|---|
-| **`_CrtSetDebugFillThreshold`** | \ |
+| **`_CrtSetDebugFillThreshold`** | `` |
This function is Microsoft-specific. For more compatibility information, see [Compatibility](../compatibility.md).
diff --git a/docs/c-runtime-library/reference/crtsetreportfile.md b/docs/c-runtime-library/reference/crtsetreportfile.md
index 35b801e080..be7c2e89e1 100644
--- a/docs/c-runtime-library/reference/crtsetreportfile.md
+++ b/docs/c-runtime-library/reference/crtsetreportfile.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _CrtSetReportFile"
title: "_CrtSetReportFile"
+description: "Learn more about: _CrtSetReportFile"
ms.date: "11/04/2016"
api_name: ["_CrtSetReportFile"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CrtSetReportFile", "_CrtSetReportFile"]
helpviewer_keywords: ["CrtSetReportFile function", "_CrtSetReportFile function"]
-ms.assetid: 3126537e-511b-44af-9c1c-0605265eabc4
---
# `_CrtSetReportFile`
@@ -91,4 +90,4 @@ The console isn't supported in Universal Windows Platform (UWP) apps. The standa
## See also
-[Debug routines](../debug-routines.md)\
+[Debug routines](../debug-routines.md)
diff --git a/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md b/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md
index ff9fcbd2f5..efbd48aaa0 100644
--- a/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md
+++ b/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md
@@ -109,7 +109,7 @@ Zero if successful. If there's a failure due to an invalid parameter, the invali
The **`ctime_s`** function converts a time value stored as a [`time_t`](../standard-types.md) structure into a character string. The *`sourceTime`* value is typically obtained from a call to [`time`](time-time32-time64.md), which returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC). The return value string contains exactly 26 characters and has the form:
-`Wed Jan 02 02:03:55 1980\n\0`
+`Wed Jan 2 02:03:55 1980\n\0`
A 24-hour clock is used. All fields have a constant width. The new line character ('\n') and the null character ('\0') occupy the last two positions of the string.
diff --git a/docs/c-runtime-library/reference/cxxthrowexception.md b/docs/c-runtime-library/reference/cxxthrowexception.md
index 1bad3b4dd0..2a2a3b87b6 100644
--- a/docs/c-runtime-library/reference/cxxthrowexception.md
+++ b/docs/c-runtime-library/reference/cxxthrowexception.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _CxxThrowException"
title: "_CxxThrowException"
+description: "Learn more about: _CxxThrowException"
ms.date: "11/04/2016"
api_name: ["_CxxThrowException"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CxxThrowException", "_CxxThrowException"]
helpviewer_keywords: ["_CxxThrowException function", "CxxThrowException function"]
-ms.assetid: 0b90bef5-b7d2-46e0-88e2-59e531e01a4d
---
# `_CxxThrowException`
@@ -18,7 +17,7 @@ Builds the exception record and calls the runtime environment to start processin
```C
extern "C" void __stdcall _CxxThrowException(
- void* pExceptionObject
+ void* pExceptionObject,
_ThrowInfo* pThrowInfo
);
```
diff --git a/docs/c-runtime-library/reference/dupenv-s-dbg-wdupenv-s-dbg.md b/docs/c-runtime-library/reference/dupenv-s-dbg-wdupenv-s-dbg.md
index cfc0b250e2..047aba34af 100644
--- a/docs/c-runtime-library/reference/dupenv-s-dbg-wdupenv-s-dbg.md
+++ b/docs/c-runtime-library/reference/dupenv-s-dbg-wdupenv-s-dbg.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _dupenv_s_dbg, _wdupenv_s_dbg"
title: "_dupenv_s_dbg, _wdupenv_s_dbg"
+description: "Learn more about: _dupenv_s_dbg, _wdupenv_s_dbg"
ms.date: "11/04/2016"
api_name: ["_dupenv_s_dbg", "_wdupenv_s_dbg"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_tdupenv_s_dbg", "_dupenv_s_dbg", "_wdupenv_s_dbg"]
helpviewer_keywords: ["_tdupenv_s_dbg function", "dupenv_s_dbg function", "_wdupenv_s_dbg function", "environment variables", "tdupenv_s_dbg function", "wdupenv_s_dbg function", "_dupenv_s_dbg function"]
-ms.assetid: e3d81148-e24e-46d0-a21d-fd87b5e6256c
---
# `_dupenv_s_dbg`, `_wdupenv_s_dbg`
@@ -88,7 +87,7 @@ For more compatibility information, see [Compatibility](../compatibility.md).
```C
// crt_dupenv_s_dbg.c
-#include
+#include
#include
int main( void )
diff --git a/docs/c-runtime-library/reference/dupenv-s-wdupenv-s.md b/docs/c-runtime-library/reference/dupenv-s-wdupenv-s.md
index e0d4242db2..da9fb11032 100644
--- a/docs/c-runtime-library/reference/dupenv-s-wdupenv-s.md
+++ b/docs/c-runtime-library/reference/dupenv-s-wdupenv-s.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _dupenv_s, _wdupenv_s"
title: "_dupenv_s, _wdupenv_s"
+description: "Learn more about: _dupenv_s, _wdupenv_s"
ms.date: "4/2/2020"
api_name: ["_dupenv_s", "_wdupenv_s", "_o__dupenv_s", "_o__wdupenv_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-environment-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["tdupenv_s", "_dupenv_s", "wdupenv_s", "dupenv_s", "_tdupenv_s", "_wdupenv_s"]
helpviewer_keywords: ["_dupenv_s function", "_tdupenv_s function", "_wdupenv_s function", "environment variables", "wdupenv_s function", "dupenv_s function", "tdupenv_s function"]
-ms.assetid: b729ecc2-a31d-4ccf-92a7-5accedb8f8c8
---
# `_dupenv_s`, `_wdupenv_s`
@@ -89,7 +88,7 @@ For more compatibility information, see [Compatibility](../compatibility.md).
```C
// crt_dupenv_s.c
-#include
+#include
int main( void )
{
diff --git a/docs/c-runtime-library/reference/exit-exit-exit.md b/docs/c-runtime-library/reference/exit-exit-exit.md
index 1ad98c4dc5..bcec154714 100644
--- a/docs/c-runtime-library/reference/exit-exit-exit.md
+++ b/docs/c-runtime-library/reference/exit-exit-exit.md
@@ -14,7 +14,7 @@ helpviewer_keywords: ["exit function", "_exit function", "processes, terminating
Terminates the calling process. The **`exit`** function terminates it after cleanup; **`_exit`** and **`_Exit`** terminate it immediately.
> [!NOTE]
-> Do not use this method to shut down a Universal Windows Platform (UWP) app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/legal/windows/agreements/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle). For more information about UWP apps, see [Universal Windows Platform documentation](https://developer.microsoft.com/windows/apps).
+> Do not use this method to shut down a Universal Windows Platform (UWP) app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/windows/apps/publish/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle). For more information about UWP apps, see [Universal Windows Platform documentation](https://developer.microsoft.com/windows/apps).
## Syntax
diff --git a/docs/c-runtime-library/reference/exp2-exp2f-exp2l.md b/docs/c-runtime-library/reference/exp2-exp2f-exp2l.md
index b2d84ff608..bf7a2e2893 100644
--- a/docs/c-runtime-library/reference/exp2-exp2f-exp2l.md
+++ b/docs/c-runtime-library/reference/exp2-exp2f-exp2l.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["exp2", "math/exp2", "exp2f", "math/exp2f", "exp2l", "math/exp2l"]
helpviewer_keywords: ["exp2 function", "exp2f function", "exp2l function"]
-ms.assetid: 526e3e10-201a-4610-a886-533f44ece344
---
# `exp2`, `exp2f`, `exp2l`
@@ -79,5 +78,5 @@ For more compatibility information, see [Compatibility](../compatibility.md).
## See also
[Alphabetical function reference](crt-alphabetical-function-reference.md)\
-[`exp`, `expf`, `expl`](exp-expf.md)
+[`exp`, `expf`, `expl`](exp-expf.md)\
[`log2`, `log2f`, `log2l`](log2-log2f-log2l.md)
diff --git a/docs/c-runtime-library/reference/fclose-nolock.md b/docs/c-runtime-library/reference/fclose-nolock.md
index ca205e0355..b03860a277 100644
--- a/docs/c-runtime-library/reference/fclose-nolock.md
+++ b/docs/c-runtime-library/reference/fclose-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _fclose_nolock"
title: "_fclose_nolock"
+description: "Learn more about: _fclose_nolock"
ms.date: "4/2/2020"
api_name: ["_fclose_nolock", "_o__fclose_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["fclose_nolock", "_fclose_nolock"]
helpviewer_keywords: ["streams, closing", "fclose_nolock function", "_fclose_nolock function"]
-ms.assetid: b4af4392-5fc8-49bb-9fe2-ca7293d3ce04
---
# `_fclose_nolock`
-Closes a stream without thread-locking.
+Closes a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/fdim-fdimf-fdiml.md b/docs/c-runtime-library/reference/fdim-fdimf-fdiml.md
index 652e9aaf6b..89145b12af 100644
--- a/docs/c-runtime-library/reference/fdim-fdimf-fdiml.md
+++ b/docs/c-runtime-library/reference/fdim-fdimf-fdiml.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["fdim", "fdimf", "fdiml", "math/fdim", "math/fdimf", "math/fdiml"]
helpviewer_keywords: ["fdim function", "fdimf function", "fdiml function"]
-ms.assetid: 2d4ac639-51e9-462d-84ab-fb03b06971a0
---
# `fdim`, `fdimf`, `fdiml`
@@ -93,4 +92,4 @@ For more compatibility information, see [Compatibility](../compatibility.md).
[Alphabetical function reference](crt-alphabetical-function-reference.md)\
[`fmax`, `fmaxf`, `fmaxl`](fmax-fmaxf-fmaxl.md)\
-[`abs`, `labs`, `llabs`, `_abs64`](abs-labs-llabs-abs64.md)\
+[`abs`, `labs`, `llabs`, `_abs64`](abs-labs-llabs-abs64.md)
diff --git a/docs/c-runtime-library/reference/fegetround-fesetround2.md b/docs/c-runtime-library/reference/fegetround-fesetround2.md
index 8a6a274159..d771b3c7d4 100644
--- a/docs/c-runtime-library/reference/fegetround-fesetround2.md
+++ b/docs/c-runtime-library/reference/fegetround-fesetround2.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["fegetround", "fesetround", "fenv/fegetround", "fenv/fesetround"]
helpviewer_keywords: ["fegetround function", "fesetround function"]
-ms.assetid: 596af00b-be2f-4f57-b2f5-460485f9ff0b
---
# `fegetround`, `fesetround`
@@ -18,10 +17,7 @@ Gets or sets the current floating-point rounding mode.
```C
int fegetround(void);
-
-int fesetround(
- int round_mode
-);
+int fesetround(int round_mode);
```
### Parameters
@@ -51,30 +47,29 @@ The default behavior of `FE_TONEAREST` is to round results midway between repres
The current rounding mode affects these operations:
- String conversions.
-
- The results of floating-point arithmetic operators outside of constant expressions.
-
- The library rounding functions, such as `rint` and `nearbyint`.
-
- Return values from standard library mathematical functions.
The current rounding mode doesn't affect these operations:
- The `trunc`, `ceil`, `floor`, and `lround` library functions.
-
- Floating-point to integer implicit casts and conversions, which always round towards zero.
-
- The results of floating-point arithmetic operators in constant expressions, which always round to the nearest value.
To use these functions, you must turn off floating-point optimizations that could prevent access by using the `#pragma fenv_access(on)` directive prior to the call. For more information, see [`fenv_access`](../../preprocessor/fenv-access.md).
+> [!IMPORTANT]
+> Prior to Windows 10 version 14393, `fenv.h` defined `FE_UPWARD = 0x0100` and `FE_DOWNWARD = 0x0200`. In Windows version 14393, this header was updated to address a bug in which some APIs would interpret `FE_UPWARD` as `FE_DOWNWARD`, and vice-versa. Starting in Windows version 14393, `FE_UPWARD = 0x0200` and `FE_DOWNWARD = 0x0100`, reversing their previous values.
+> If you compiled your app against an old Windows SDK version (this issue depends on SDK version, not OS version or VS version) you might encounter this issue. Update your app to target the latest Windows SDK so that the definitions of `FE_UPWARD` and `FE_DOWNWARD` are consistent with the Windows implementation. If you can't update your app to target a later Windows SDK, you can define `FE_UPWARD` as `0x0100` and `FE_DOWNWARD` as `0x0200` in your code.
+
## Requirements
| Function | C header | C++ header |
|---|---|---|
-| **`fegetround`**, **`fesetround`** | \ | \ |
+| **`fegetround`**, **`fesetround`** | `` | `` |
-For more compatibility information, see [Compatibility](../compatibility.md).
+For more information, see [Compatibility](../compatibility.md).
## See also
diff --git a/docs/c-runtime-library/reference/fflush-nolock.md b/docs/c-runtime-library/reference/fflush-nolock.md
index 2934639b30..4c83497bc9 100644
--- a/docs/c-runtime-library/reference/fflush-nolock.md
+++ b/docs/c-runtime-library/reference/fflush-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _fflush_nolock"
title: "_fflush_nolock"
+description: "Learn more about: _fflush_nolock"
ms.date: "4/2/2020"
api_name: ["_fflush_nolock", "_o__fflush_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["fflush_nolock", "_fflush_nolock"]
helpviewer_keywords: ["fflush_nolock function", "_fflush_nolock function", "streams, flushing", "flushing"]
-ms.assetid: 5e33c4a1-b10c-4001-ad01-210757919291
---
# `_fflush_nolock`
-Flushes a stream without locking the thread.
+Flushes a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/fgetc-nolock-fgetwc-nolock.md b/docs/c-runtime-library/reference/fgetc-nolock-fgetwc-nolock.md
index 6ef2d4d806..59604586b6 100644
--- a/docs/c-runtime-library/reference/fgetc-nolock-fgetwc-nolock.md
+++ b/docs/c-runtime-library/reference/fgetc-nolock-fgetwc-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _fgetc_nolock, _fgetwc_nolock"
title: "_fgetc_nolock, _fgetwc_nolock"
+description: "Learn more about: _fgetc_nolock, _fgetwc_nolock"
ms.date: "4/2/2020"
api_name: ["_fgetc_nolock", "_fgetwc_nolock", "_o__fgetc_nolock", "_o__fgetwc_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_fgetwc_nolock", "fgettc_nolock", "fgetwc_nolock", "_fgetc_nolock", "_fgettc_nolock", "fgetc_nolock"]
helpviewer_keywords: ["fgetc_nolock function", "fgetwc_nolock function", "_fgetwc_nolock function", "characters, reading", "_fgetc_nolock function", "streams, reading characters from", "fgettc_nolock function", "reading characters from streams", "_fgettc_nolock function"]
-ms.assetid: fb8e7c5b-4503-493a-879e-6a1db75aa114
---
# `_fgetc_nolock`, `_fgetwc_nolock`
-Reads a character from a stream without locking the thread.
+Reads a character from a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/findfirst-functions.md b/docs/c-runtime-library/reference/findfirst-functions.md
index d34d13c777..dcfbffe363 100644
--- a/docs/c-runtime-library/reference/findfirst-functions.md
+++ b/docs/c-runtime-library/reference/findfirst-functions.md
@@ -72,7 +72,7 @@ intptr_t _wfindfirst64i32(
Target file specification (can include wildcard characters).
*`fileinfo`*\
-File information buffer.
+File information buffer. For more information about the `fileinfo` structs, see the Remarks in [Filename search functions](../filename-search-functions.md) and see [Data type mappings](../data-type-mappings.md). The structs are defined in the same header file as the function that uses them as a parameter.
## Return value
@@ -101,7 +101,7 @@ These functions use various forms of the **`_finddata_t`** structure for the *`f
The variations that use a 64-bit time type enable file-creation dates to be expressed up through 23:59:59, December 31, 3000, UTC. The ones that use 32-bit time types represent dates only through 23:59:59 January 18, 2038, UTC. Midnight, January 1, 1970, is the lower bound of the date range for all these functions.
-Unless you have a specific reason to use the versions that specify the time size explicitly, use **`_findfirst`** or **`_wfindfirst`** or, if you need to support file sizes larger than 3 GB, use **`_findfirsti64`** or **`_wfindfirsti64`**. All these functions use the 64-bit time type. In earlier versions, these functions used a 32-bit time type. If this change is a breaking change for an application, you might define `_USE_32BIT_TIME_T` to revert to the old behavior. If `_USE_32BIT_TIME_T` is defined, **`_findfirst`**, **`_finfirsti64`**, and their corresponding Unicode versions use a 32-bit time.
+Unless you have a specific reason to use the versions that specify the time size explicitly, use **`_findfirst`** or **`_wfindfirst`** or, if you need to support file sizes larger than 3 GB, use **`_findfirsti64`** or **`_wfindfirsti64`**. All these functions use the 64-bit time type. In earlier versions, these functions used a 32-bit time type. If this change is a breaking change for an application, you might define `_USE_32BIT_TIME_T` to revert to the old behavior. If `_USE_32BIT_TIME_T` is defined, **`_findfirst`**, **`_findfirsti64`**, and their corresponding Unicode versions use a 32-bit time.
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
diff --git a/docs/c-runtime-library/reference/floating-point-ordering.md b/docs/c-runtime-library/reference/floating-point-ordering.md
index ece44b97be..acdf45961d 100644
--- a/docs/c-runtime-library/reference/floating-point-ordering.md
+++ b/docs/c-runtime-library/reference/floating-point-ordering.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered"
title: "isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered"
+description: "Learn more about: isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered"
ms.date: "01/31/2019"
f1_keywords: ["isgreater", "math/isgreater", "isgreaterequal", "math/isgreaterequal", "isless", "math/isless", "islessequal", "math/islessequal", "islessgreater", "math/islessgreater", "isunordered", "math/isunordered"]
helpviewer_keywords: ["isgreater function", "isgreaterequal function", "isless function", "islessequal function", "islessgreater function", "isunordered function"]
@@ -43,7 +43,7 @@ int isunordered(
); /* C-only macro */
```
-```C++
+```cpp
template
inline bool isgreater(
FloatingType1 x,
diff --git a/docs/c-runtime-library/reference/fma-fmaf-fmal.md b/docs/c-runtime-library/reference/fma-fmaf-fmal.md
index 7838e4e7d1..5c1d6f5f4b 100644
--- a/docs/c-runtime-library/reference/fma-fmaf-fmal.md
+++ b/docs/c-runtime-library/reference/fma-fmaf-fmal.md
@@ -1,6 +1,6 @@
---
title: "fma, fmaf, fmal"
-description: "API reference for fma, fmaf, and fmal; which multiplies two values together, adds a third value, and then rounds the result, without losing any precision due to intermediary rounding."
+description: "API reference for fma, fmaf, and fmal; which multiplies two values together, adds a third value, and then rounds the result, while only losing a small amount of precision due to intermediary rounding."
ms.date: "9/1/2020"
api_name: ["fma", "fmaf", "fmal", "_o_fma", "_o_fmaf", "_o_fmal"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-math-l1-1-0.dll"]
@@ -12,7 +12,7 @@ ms.assetid: 584a6037-da1e-4e86-9f0c-97aae86de0c0
---
# `fma`, `fmaf`, `fmal`
-Multiplies two values together, adds a third value, and then rounds the result, without losing any precision due to intermediary rounding.
+Multiplies two values together, adds a third value, and then rounds the result, while only losing a small amount of precision due to intermediary rounding.
## Syntax
@@ -63,7 +63,7 @@ The value to add.
## Return value
-Returns `(x * y) + z`. The return value is then rounded using the current rounding format.
+Returns approximately `(x * y) + z`. The return value is then rounded using the current rounding format, although in many cases, it returns incorrectly rounded results and thus the value may be inexact by up to half an ulp from the correct value.
Otherwise, may return one of the following values:
diff --git a/docs/c-runtime-library/reference/fopen-s-wfopen-s.md b/docs/c-runtime-library/reference/fopen-s-wfopen-s.md
index 47072fb31b..6964db2b65 100644
--- a/docs/c-runtime-library/reference/fopen-s-wfopen-s.md
+++ b/docs/c-runtime-library/reference/fopen-s-wfopen-s.md
@@ -1,7 +1,7 @@
---
title: "fopen_s, _wfopen_s"
description: "Describes the API for `fopen_s` and `_wfopen_s`"
-ms.date: 05/18/2022
+ms.date: 04/27/2023
api_name: ["_wfopen_s", "fopen_s", "_o__wfopen_s", "_o_fopen_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
api_type: ["DLLExport"]
@@ -31,10 +31,10 @@ errno_t _wfopen_s(
### Parameters
*`pFile`*\
-A pointer to the file pointer that will receive the pointer to the opened file.
+A pointer to the file pointer that receives the pointer to the opened file.
*`filename`*\
-Filename.
+The name of the file to open.
*`mode`*\
Type of access permitted.
@@ -55,7 +55,7 @@ Zero if successful; an error code on failure. For more information about these e
The **`fopen_s`** and **`_wfopen_s`** functions can't open a file for sharing. If you need to share the file, use [`_fsopen` or `_wfsopen`](fsopen-wfsopen.md) with the appropriate sharing mode constant—for example, use `_SH_DENYNO` for read/write sharing.
-The **`fopen_s`** function opens the file that's specified by *`filename`*. **`_wfopen_s`** is a wide-character version of **`fopen_s`**; the arguments to **`_wfopen_s`** are wide-character strings. **`_wfopen_s`** and **`fopen_s`** behave identically otherwise.
+The **`fopen_s`** function opens the file specified by *`filename`*. **`_wfopen_s`** is a wide-character version of **`fopen_s`** and the arguments to **`_wfopen_s`** are wide-character strings. **`_wfopen_s`** and **`fopen_s`** behave identically, otherwise.
**`fopen_s`** accepts paths that are valid on the file system at the point of execution; UNC paths and paths that involve mapped network drives are accepted by **`fopen_s`** as long as the system that's executing the code has access to the share or mapped network drive at the time of execution. When you construct paths for **`fopen_s`**, don't make assumptions about the availability of drives, paths, or network shares in the execution environment. You can use either forward slashes (/) or backslashes (\\) as the directory separators in a path.
@@ -111,14 +111,14 @@ When the **`"r+"`**, **`"w+"`**, or **`"a+"`** access type is specified, both re
Starting in C11, you can append **`"x"`** to **`"w"`** or **`"w+"`** to cause the function fail if the file exists, instead of overwriting it.
-In addition to the values above, the following characters can be included in *`mode`* to specify the translation mode for newline characters:
+In addition to the previous values, the following characters can be included in *`mode`* to specify the translation mode for newline characters:
| *`mode`* modifier | Translation mode |
|--|--|
-| **`t`** | Open in text (translated) mode. |
+| **`t`** | Open in text (translated) mode. Carriage return-line feed (CR-LF) combinations are translated into single line feeds (LF) on input and LF characters are translated to CR-LF combinations on output. CTRL+Z is interpreted as an end-of-file character on input. |
| **`b`** | Open in binary (untranslated) mode; translations involving carriage-return and line feed characters are suppressed. |
-In text (translated) mode, `CTRL`+**Z** is interpreted as an end-of-file character on input. In files opened for reading/writing with **`"a+"`**, **`fopen_s`** checks for a `CTRL`+**Z** at the end of the file and removes it, if possible. It's removed because using [`fseek`](fseek-fseeki64.md) and [`ftell`](ftell-ftelli64.md) to move within a file that ends with a `CTRL`+**Z**, may cause **`fseek`** to behave improperly near the end of the file.
+In text (translated) mode, `CTRL`+**Z** is interpreted as an end-of-file character on input. For files opened for reading/writing with **`"a+"`**, **`fopen_s`** checks for a `CTRL`+**Z** at the end of the file and removes it, if possible. It's removed because using [`fseek`](fseek-fseeki64.md) and [`ftell`](ftell-ftelli64.md) to move within a file that ends with a `CTRL`+**Z**, may cause **`fseek`** to behave improperly near the end of the file.
Also, in text mode, carriage return/line feed (CRLF) combinations are translated into single line feed (LF) characters on input, and LF characters are translated to CRLF combinations on output. When a Unicode stream-I/O function operates in text mode (the default), the source or destination stream is assumed to be a sequence of multibyte characters. The Unicode stream-input functions convert multibyte characters to wide characters (as if by a call to the **`mbtowc`** function). For the same reason, the Unicode stream-output functions convert wide characters to multibyte characters (as if by a call to the **`wctomb`** function).
@@ -133,8 +133,8 @@ For more information about using text and binary modes in Unicode and multibyte
| **`N`** | Specifies that the file isn't inherited by child processes. |
| **`S`** | Specifies that caching is optimized for, but not restricted to, sequential access from disk. |
| **`R`** | Specifies that caching is optimized for, but not restricted to, random access from disk. |
-| **`t`** | Specifies a file as temporary. If possible, it isn't flushed to disk. |
-| **`D`** | Specifies a file as temporary. It's deleted when the last file pointer is closed. |
+| **`T`** | Specifies a file that isn't written to disk unless memory pressure requires it. |
+| **`D`** | Specifies a temporary file that is deleted when the last file pointer to it is closed. |
| **`ccs=UNICODE`** | Specifies UNICODE as the encoded character set to use for this file. Leave unspecified if you want ANSI encoding. |
| **`ccs=UTF-8`** | Specifies UTF-8 as the encoded character set to use for this file. Leave unspecified if you want ANSI encoding. |
| **`ccs=UTF-16LE`** | Specifies UTF-16LE as the encoded character set to use for this file. Leave unspecified if you want ANSI encoding. |
@@ -150,21 +150,27 @@ Valid characters for the *`mode`* string used in **`fopen_s`** and [`_fdopen`](f
| **`w`** | `_O_WRONLY` (usually `_O_WRONLY | _O_CREAT | _O_TRUNC`) |
| **`w+`** | `_O_RDWR` (usually **`_O_RDWR | _O_CREAT | _O_TRUNC`) |
| **`b`** | `_O_BINARY` |
-| **`t`** | `_O_TEXT` |
+| **`t`** | `_O_TEXT` (translated) |
| **`c`** | None |
| **`n`** | None |
-| **`S`** | `_O_SEQUENTIAL` |
-| **`R`** | `_O_RANDOM` |
-| **`t`** | `_O_SHORTLIVED` |
+| **`N`** | `_O_NOINHERIT` |
| **`D`** | `_O_TEMPORARY` |
+| **`R`** | `_O_RANDOM` |
+| **`S`** | `_O_SEQUENTIAL` |
+| **`T`** | `_O_SHORTLIVED` |
| **`ccs=UNICODE`** | `_O_WTEXT` |
| **`ccs=UTF-8`** | `_O_UTF8` |
| **`ccs=UTF-16LE`** | `_O_UTF16` |
-The **`c`**, **`n`**, and **`t`** *`mode`* options are Microsoft extensions for **`fopen_s`** and [`_fdopen`](fdopen-wfdopen.md) and shouldn't be used where you want ANSI portability.
+The **`c`**, **`n`**, **`R`**, **`S`**, **`t`**, **`T`**, and **`D`** *`mode`* options are Microsoft extensions for `fopen_s` and `_wfopen_s` and shouldn't be used when you want ANSI portability.
If you're using **`rb`** mode, memory mapped Win32 files might also be an option if you don't need to port your code, you expect to read much of the file, or you don't care about network performance.
+Regarding `T` and `D`:
+- `T` avoids writing the file to disk as long as memory pressure doesn't require it. For more information, see `FILE_ATTRIBUTE_TEMPORARY` in [File attribute constants](/windows/win32/fileio/file-attribute-constants), and also this blog post [It's only temporary](/archive/blogs/larryosterman/its-only-temporary).
+- `D` specifies a regular file that is written to disk. The difference is that it's automatically deleted when it's closed.
+You can combine `TD` to get both semantics.
+
## Requirements
| Function | Required header | C++ header |
diff --git a/docs/c-runtime-library/reference/fopen-wfopen.md b/docs/c-runtime-library/reference/fopen-wfopen.md
index 2a7036a39a..22d44f2421 100644
--- a/docs/c-runtime-library/reference/fopen-wfopen.md
+++ b/docs/c-runtime-library/reference/fopen-wfopen.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: fopen, _wfopen"
title: "fopen, _wfopen"
-ms.date: 05/18/2022
+description: "Learn more about: fopen, _wfopen"
+ms.date: 04/27/2023
api_name: ["_wfopen", "fopen", "_o__wfopen", "_o_fopen"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
api_type: ["DLLExport"]
@@ -42,9 +42,9 @@ For more information, see [`errno`, `_doserrno`, `_sys_errlist`, and `_sys_nerr`
## Remarks
-The **`fopen`** function opens the file that is specified by *`filename`*. By default, a narrow *`filename`* string is interpreted using the ANSI codepage (`CP_ACP`). In Windows Desktop applications, it can be changed to the OEM codepage (`CP_OEMCP`) by using the [`SetFileApisToOEM`](/windows/win32/api/fileapi/nf-fileapi-setfileapistooem) function. You can use the [`AreFileApisANSI`](/windows/win32/api/fileapi/nf-fileapi-arefileapisansi) function to determine whether *`filename`* is interpreted using the ANSI or the system default OEM codepage. **`_wfopen`** is a wide-character version of **`fopen`**; the **`_wfopen`** arguments are wide-character strings. Otherwise, **`_wfopen`** and **`fopen`** behave identically. Just using **`_wfopen`** doesn't affect the coded character set that's used in the file stream.
+The **`fopen`** function opens the file specified by *`filename`*. By default, a narrow *`filename`* string is interpreted using the ANSI codepage (`CP_ACP`). In Windows Desktop applications, it can be changed to the OEM codepage (`CP_OEMCP`) by using the [`SetFileApisToOEM`](/windows/win32/api/fileapi/nf-fileapi-setfileapistooem) function. You can use the [`AreFileApisANSI`](/windows/win32/api/fileapi/nf-fileapi-arefileapisansi) function to determine whether *`filename`* is interpreted using the ANSI or the system default OEM codepage. **`_wfopen`** is a wide-character version of **`fopen`**; the **`_wfopen`** arguments are wide-character strings. Otherwise, **`_wfopen`** and **`fopen`** behave identically. Just using **`_wfopen`** doesn't affect the coded character set that's used in the file stream.
-**`fopen`** accepts paths that are valid on the file system at the point of execution; **`fopen`** accepts UNC paths and paths that involve mapped network drives as long as the system that executes the code has access to the share or mapped drive at the time of execution. When you construct paths for **`fopen`**, make sure that drives, paths, or network shares will be available in the execution environment. You can use either forward slashes (`/`) or backslashes (`\`) as the directory separators in a path.
+**`fopen`** accepts paths that are valid on the file system at the point of execution; **`fopen`** accepts UNC paths and paths that involve mapped network drives as long as the system that executes the code has access to the share or mapped drive at the time of execution. When you construct paths for **`fopen`**, make sure that drives, paths, or network shares are available in the execution environment. You can use either forward slashes (`/`) or backslashes (`\`) as the directory separators in a path.
Always check the return value to see whether the pointer is NULL before you perform any other operations on the file. If an error occurs, the global variable `errno` is set, and may be used to obtain specific error information. For more information, see [`errno`, `_doserrno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
@@ -60,7 +60,7 @@ Allowed values for **`ccs`** encoding are `UNICODE`, **`UTF-8`**, and **`UTF-16L
When a file is opened in Unicode mode, input functions translate the data that's read from the file into UTF-16 data stored as type **`wchar_t`**. Functions that write to a file opened in Unicode mode expect buffers that contain UTF-16 data stored as type **`wchar_t`**. If the file is encoded as UTF-8, then UTF-16 data is translated into UTF-8 when it's written. The file's UTF-8-encoded content is translated into UTF-16 when it's read. An attempt to read or write an odd number of bytes in Unicode mode causes a [parameter validation](../parameter-validation.md) error. To read or write data that's stored in your program as UTF-8, use a text or binary file mode instead of a Unicode mode. You're responsible for any required encoding translation.
-If the file already exists and is opened for reading or appending, then any byte order mark (BOM) in the file determines the encoding. The BOM encoding takes precedence over the encoding that's specified by the **`ccs`** flag. The **`ccs`** encoding is only used when no BOM is present or the file is a new file.
+If the file already exists and is opened for reading or appending, then any byte order mark (BOM) in the file determines the encoding. The BOM encoding takes precedence over the encoding specified by the **`ccs`** flag. The **`ccs`** encoding is only used when no BOM is present or the file is a new file.
> [!NOTE]
> BOM detection only applies to files that are opened in Unicode mode (that is, by passing the **`ccs`** flag).
@@ -77,7 +77,7 @@ The following table summarizes the modes that are used for various **`ccs`** fla
Files opened for writing in Unicode mode have a BOM written to them automatically.
-If *`mode`* is **`a, ccs=encoding`** for some `encoding` value, **`fopen`** first tries to open the file by using both read and write access. If this action succeeds, the function reads the BOM to determine the encoding for the file. If it fails, the function uses the default encoding for the file. In either case, **`fopen`** will then reopen the file by using write-only access. (This behavior applies to **`"a"`** mode only, not to **`"a+"`** mode.)
+If *`mode`* is **`a, ccs=encoding`** for some `encoding` value, **`fopen`** first tries to open the file by using both read and write access. If this action succeeds, the function reads the BOM to determine the encoding for the file. If it fails, the function uses the default encoding for the file. In either case, **`fopen`** reopens the file using write-only access. (This behavior applies to **`"a"`** mode only, not to **`"a+"`** mode.)
### Generic-text routine mappings
@@ -106,7 +106,7 @@ In addition to the earlier values, the following characters can be appended to *
| *`mode`* modifier | Translation mode |
|--|--|
-| **`t`** | Open in text (translated) mode. |
+| **`t`** | Open in text (translated) mode. Carriage return-line feed (CR-LF) combinations are translated into single line feeds (LF) on input and LF characters are translated to CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. |
| **`b`** | Open in binary (untranslated) mode; translations involving carriage-return and line feed characters are suppressed. |
In text mode, `CTRL`+**Z** is interpreted as an EOF character on input. In files that are opened for reading/writing by using **`"a+"`**, **`fopen`** checks for a `CTRL`+**Z** at the end of the file and removes it, if it's possible. It's removed because using [`fseek`](fseek-fseeki64.md) and **`ftell`** to move within a file that ends with `CTRL`+**Z** may cause [`fseek`](fseek-fseeki64.md) to behave incorrectly near the end of the file.
@@ -127,8 +127,8 @@ The following options can be appended to *`mode`* to specify more behaviors.
| **`N`** | Specifies that the file isn't inherited by child processes. |
| **`S`** | Specifies that caching is optimized for, but not restricted to, sequential access from disk. |
| **`R`** | Specifies that caching is optimized for, but not restricted to, random access from disk. |
-| **`T`** | Specifies a file as temporary. If possible, it isn't flushed to disk. |
-| **`D`** | Specifies a file as temporary. It's deleted when the last file pointer is closed. |
+| **`T`** | Specifies a file that isn't written to disk unless memory pressure requires it. |
+| **`D`** | Specifies a temporary file that's deleted when the last file pointer to it is closed. |
| **`ccs=encoding`** | Specifies the encoded character set to use (one of **`UTF-8`**, **`UTF-16LE`**, or `UNICODE`) for this file. Leave unspecified if you want ANSI encoding. This flag is separated from flags that precede it by a comma (`,`). For example: `FILE *f = fopen("newfile.txt", "rt+, ccs=UTF-8");` |
Valid characters for the *`mode`* string that is used in **`fopen`** and **`_fdopen`** correspond to *`oflag`* arguments that are used in [`_open`](open-wopen.md) and [`_sopen`](sopen-wsopen.md), as follows.
@@ -136,16 +136,17 @@ Valid characters for the *`mode`* string that is used in **`fopen`** and **`_fdo
| Characters in *`mode`* string | Equivalent *`oflag`* value for `_open`/`_sopen` |
|--|--|
| **`a`** | `_O_WRONLY | _O_APPEND` (usually `_O_WRONLY | _O_CREAT | _O_APPEND`) |
-| **`a+`** | `_O_RDWR | _O_APPEND` (usually `_O_RDWR | _O_APPEND | _O_CREAT` ) |
+| **`a+`** | `_O_RDWR | _O_APPEND` (usually `_O_RDWR | _O_APPEND | _O_CREAT`) |
| **`r`** | `_O_RDONLY` |
| **`r+`** | `_O_RDWR` |
| **`w`** | `_O_WRONLY` (usually `_O_WRONLY | _O_CREAT | _O_TRUNC`) |
| **`w+`** | `_O_RDWR` (usually `_O_RDWR | _O_CREAT | _O_TRUNC`) |
| **`b`** | `_O_BINARY` |
-| **`t`** | `_O_TEXT` |
+| **`t`** | `_O_TEXT` (translated) |
| **`x`** | `_O_EXCL` |
| **`c`** | None |
| **`n`** | None |
+| **`N`** | `_O_NOINHERIT` |
| **`S`** | `_O_SEQUENTIAL` |
| **`R`** | `_O_RANDOM` |
| **`T`** | `_O_SHORTLIVED` |
@@ -156,6 +157,13 @@ Valid characters for the *`mode`* string that is used in **`fopen`** and **`_fdo
If you're using **`rb`** mode, you don't have to port your code, and if you expect to read most of a large file or aren't concerned about network performance, you might also consider whether to use memory mapped Win32 files as an option.
+Regarding `T` and `D`:
+- `T` avoids writing the file to disk as long as memory pressure doesn't require it. For more information, see `FILE_ATTRIBUTE_TEMPORARY` in [File attribute constants](/windows/win32/fileio/file-attribute-constants), and also this blog post [It's only temporary](/archive/blogs/larryosterman/its-only-temporary).
+- `D` specifies a regular file that is written to disk. The difference is that it's automatically deleted when it's closed.
+You can combine `TD` to get both semantics.
+
+The **`c`**, **`n`**, **`R`**, **`S`**, **`t`**, **`T`**, and **`D`** *`mode`* options are Microsoft extensions for `fopen` and `_wfopen` and shouldn't be used when you want ANSI portability.
+
## Requirements
| Function | Required header |
diff --git a/docs/c-runtime-library/reference/fprintf-fprintf-l-fwprintf-fwprintf-l.md b/docs/c-runtime-library/reference/fprintf-fprintf-l-fwprintf-fwprintf-l.md
index 184d2fc5e9..2d972d963a 100644
--- a/docs/c-runtime-library/reference/fprintf-fprintf-l-fwprintf-fwprintf-l.md
+++ b/docs/c-runtime-library/reference/fprintf-fprintf-l-fwprintf-fwprintf-l.md
@@ -1,18 +1,20 @@
---
-description: "Learn more about: fprintf, _fprintf_l, fwprintf, _fwprintf_l"
-title: "fprintf, _fprintf_l, fwprintf, _fwprintf_l"
+description: "Learn more about: fprintf, _fprintf_l, fwprintf, _ftprintf, _ftprintf_l"
+title: "fprintf, _fprintf_l, fwprintf, _fwprintf_l, _ftprintf, _ftprintf_l"
ms.date: "3/9/2021"
-api_name: ["fwprintf", "fprintf", "_fprintf_l", "_fwprintf_l"]
+api_name: ["fwprintf", "fprintf", "_fprintf_l", "_fwprintf_l", "_ftprintf", "_ftprintf_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["fprintf", "fwprintf", "_ftprintf"]
-helpviewer_keywords: ["_fwprintf_l function", "fprintf function", "fprintf_l function", "_fprintf_l function", "_ftprintf function", "fwprintf function", "ftprintf_l function", "ftprintf function", "_ftprintf_l function", "print formatted data to streams", "fwprintf_l function"]
+f1_keywords: ["fprintf", "fwprintf", "_ftprintf", "_fwprintf_l", "_ftprintf_l"]
+helpviewer_keywords: ["fprintf function", "fprintf_l function", "_fprintf_l function", "_ftprintf function", "fwprintf function", "ftprintf_l function", "ftprintf function", "print formatted data to streams", "fwprintf_l function", "_ftprintf_l function"]
---
-# `fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`
+# `fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`, `_ftprintf`, `_ftprintf_l`
Print formatted data to a stream. More secure versions of these functions are available; see [`fprintf_s`, `_fprintf_s_l`, `fwprintf_s`, `_fwprintf_s_l`](fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md).
+For `_ftprintf` and `_ftprintf_l`, see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -73,12 +75,14 @@ The versions of these functions with the **`_l`** suffix are identical except th
>
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` function | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
-| **`_ftprintf`** | **`fprintf`** | **`fprintf`** | **`fwprintf`** |
-| **`_ftprintf_l`** | **`_fprintf_l`** | **`_fprintf_l`** | **`_fwprintf_l`** |
+| `_ftprintf` | `fprintf` | `fprintf` | `fwprintf` |
+| `_ftprintf_l` | `_fprintf_l` | `_fprintf_l` | `_fwprintf_l` |
For more information, see [Format specification syntax](../format-specification-syntax-printf-and-wprintf-functions.md).
diff --git a/docs/c-runtime-library/reference/fprintf-p-fprintf-p-l-fwprintf-p-fwprintf-p-l.md b/docs/c-runtime-library/reference/fprintf-p-fprintf-p-l-fwprintf-p-fwprintf-p-l.md
index 877bf4a16d..8ed284f343 100644
--- a/docs/c-runtime-library/reference/fprintf-p-fprintf-p-l-fwprintf-p-fwprintf-p-l.md
+++ b/docs/c-runtime-library/reference/fprintf-p-fprintf-p-l-fwprintf-p-fwprintf-p-l.md
@@ -1,18 +1,20 @@
---
-description: "Learn more about: _fprintf_p, _fprintf_p_l, _fwprintf_p, _fwprintf_p_l"
+description: "Learn more about: _fprintf_p, _fprintf_p_l, _ftprintf_p, _ftprintf_p_l, _fwprintf_p, _fwprintf_p_l"
title: "_fprintf_p, _fprintf_p_l, _fwprintf_p, _fwprintf_p_l"
ms.date: "3/9/2021"
api_name: ["_fwprintf_p", "_fprintf_p_l", "_fwprintf_p_l", "_fprintf_p"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["_fprintf_p", "_ftprintf_p", "fwprintf_p", "_fwprintf_p", "fprintf_p", "ftprintf_p"]
-helpviewer_keywords: ["fprintf_p_l function", "fprintf_p function", "_fprintf_p_l function", "_fprintf_p function", "_ftprintf_p_l function", "streams, printing formatted data to", "_fwprintf_p function", "fwprintf_p function", "_ftprintf_p function", "_fwprintf_p_l function", "ftprintf_p function", "printing [C++], formatted data to streams", "ftprintf_p_l function", "fwprintf_p_l function"]
+f1_keywords: ["_fprintf_p", "_ftprintf_p", "_ftprintf_p_l", "fwprintf_p", "_fwprintf_p", "fprintf_p", "ftprintf_p", "_fwprintf_p_l"]
+helpviewer_keywords: ["fprintf_p_l function", "fprintf_p function", "_fprintf_p_l function", "_fprintf_p function", "_ftprintf_p function", "_ftprintf_p_l function", "streams, printing formatted data to", "_fwprintf_p function", "fwprintf_p function", "_fwprintf_p_l function", "ftprintf_p function", "printing [C++], formatted data to streams", "ftprintf_p_l function", "fwprintf_p_l function"]
---
-# `_fprintf_p`, `_fprintf_p_l`, `_fwprintf_p`, `_fwprintf_p_l`
+# `_fprintf_p`, `_fprintf_p_l`, `_ftprintf_p`, `_ftprintf_p_l`, `_fwprintf_p`, `_fwprintf_p_l`
Prints formatted data to a stream.
+For `_ftprintf_p` and `_ftprintf_p_l`, see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -73,12 +75,14 @@ The versions of these functions with the `_l` suffix are identical except that t
Like the non-secure versions (see [`fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`](fprintf-fprintf-l-fwprintf-fwprintf-l.md)), these functions validate their parameters and invoke the invalid parameter handler, as described in [Parameter validation](../parameter-validation.md), if either *`stream`* or *`format`* is a null pointer or if there are any unknown or badly formed formatting specifiers. If execution is allowed to continue, the functions return -1 and set `errno` to `EINVAL`.
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| Tchar.h routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` function | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
-| `_ftprintf_p` | **`_fprintf_p`** | **`_fprintf_p`** | **`_fwprintf_p`** |
-| `_ftprintf_p_l` | **`_fprintf_p_l`** | **`_fprintf_p_l`** | **`_fwprintf_p_l`** |
+| `_ftprintf_p` | `_fprintf_p` | `_fprintf_p` | `_fwprintf_p` |
+| `_ftprintf_p_l` | `_fprintf_p_l` | `_fprintf_p_l` | `_fwprintf_p_l` |
For more information, see [Format specification syntax](../format-specification-syntax-printf-and-wprintf-functions.md).
@@ -86,8 +90,8 @@ For more information, see [Format specification syntax](../format-specification-
| Function | Required header |
|---|---|
-| **`_fprintf_p`**, **`_fprintf_p_l`** | \ |
-| **`_fwprintf_p`**, **`_fwprintf_p_l`** | \ or \ |
+| `_fprintf_p`, `_fprintf_p_l` | `` |
+| `_fwprintf_p`, `_fwprintf_p_l` | `` or `` |
For more compatibility information, see [Compatibility](../compatibility.md).
diff --git a/docs/c-runtime-library/reference/fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md b/docs/c-runtime-library/reference/fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md
index 9cdfdff5fc..225ec4abc7 100644
--- a/docs/c-runtime-library/reference/fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md
+++ b/docs/c-runtime-library/reference/fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md
@@ -1,18 +1,20 @@
---
-description: "Learn more about: fprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_l"
-title: "fprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_l"
+description: "Learn more about: fprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_l, _ftprintf_s, _ftprintf_s_l"
+title: "fprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_l, _ftprintf_s, _ftprintf_s_l"
ms.date: "3/9/2021"
-api_name: ["_fprintf_s_l", "fwprintf_s", "fprintf_s", "_fwprintf_s_l"]
+api_name: ["_fprintf_s_l", "fwprintf_s", "fprintf_s", "_fwprintf_s_l", "_ftprintf_s", "_ftprintf_s_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["_ftprintf_s", "fprintf_s", "fwprintf_s"]
-helpviewer_keywords: ["ftprintf_s_l function", "ftprintf_s function", "_fprintf_s_l function", "_ftprintf_s function", "_ftprintf_s_l function", "fwprintf_s_l function", "fwprintf_s function", "fprintf_s_l function", "fprintf_s function", "_fwprintf_s_l function", "print formatted data to streams"]
+f1_keywords: ["_ftprintf_s", "_ftprintf_s_l", "fprintf_s", "fwprintf_s", "_fwprintf_s_l", "_ftprintf", "_ftprintf_l"]
+helpviewer_keywords: ["ftprintf_s_l function", "ftprintf_s function", "_ftprintf_l function", "_fprintf_s_l function", "_ftprintf_s function", "_ftprintf_s_l function", "fwprintf_s_l function", "fwprintf_s function", "fprintf_s_l function", "fprintf_s function", "_fwprintf_s_l function", "_fwprintf_s_l function", "print formatted data to streams"]
---
-# `fprintf_s`, `_fprintf_s_l`, `fwprintf_s`, `_fwprintf_s_l`
+# `fprintf_s`, `_fprintf_s_l`, `fwprintf_s`, `_fwprintf_s_l`, `_ftprintf`, `_ftprintf_l`, `_ftprintf_s`, `_ftprintf_s_l`
Print formatted data to a stream. These functions are versions of [`fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`](fprintf-fprintf-l-fwprintf-fwprintf-l.md) with security enhancements as described in [Security features in the CRT](../security-features-in-the-crt.md).
+For `_ftprintf_s` and `_ftprintf_s_l`, see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -69,17 +71,18 @@ The versions of these functions with the **`_l`** suffix are identical except th
> [!IMPORTANT]
> Ensure that *`format`* is not a user-defined string.
>
->
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
Like the non-secure versions (see [`fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`](fprintf-fprintf-l-fwprintf-fwprintf-l.md)), these functions validate their parameters and invoke the invalid parameter handler, as described in [Parameter validation](../parameter-validation.md), if either *`stream`* or *`format`* is a `NULL` pointer. The format string itself is also validated. If there are any unknown or badly formed formatting specifiers, these functions generate the invalid parameter exception. In all cases, If execution is allowed to continue, the functions return -1 and set `errno` to `EINVAL`. For more information about return codes, see [`errno`, `_doserrno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` function | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
-| **`_ftprintf_s`** | **`fprintf_s`** | **`fprintf_s`** | **`fwprintf_s`** |
-| **`_ftprintf_s_l`** | **`_fprintf_s_l`** | **`_fprintf_s_l`** | **`_fwprintf_s_l`** |
+| `_ftprintf_s` | `fprintf_s` | `fprintf_s` | `fwprintf_s` |
+| `_ftprintf_s_l` | `_fprintf_s_l` | `_fprintf_s_l` | `_fwprintf_s_l` |
For more information, see [Format specification syntax](../format-specification-syntax-printf-and-wprintf-functions.md).
diff --git a/docs/c-runtime-library/reference/fputc-nolock-fputwc-nolock.md b/docs/c-runtime-library/reference/fputc-nolock-fputwc-nolock.md
index b5e7c99d06..ded60efc1b 100644
--- a/docs/c-runtime-library/reference/fputc-nolock-fputwc-nolock.md
+++ b/docs/c-runtime-library/reference/fputc-nolock-fputwc-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _fputc_nolock, _fputwc_nolock"
title: "_fputc_nolock, _fputwc_nolock"
+description: "Learn more about: _fputc_nolock, _fputwc_nolock"
ms.date: "4/2/2020"
api_name: ["_fputwc_nolock", "_fputc_nolock", "_o__fputc_nolock", "_o__fputwc_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_fputc_nolock", "fputwc_nolock", "fputc_nolock", "fputtc_nolock", "_fputwc_nolock", "_fputtc_nolock"]
helpviewer_keywords: ["streams, writing characters to", "fputwc_nolock function", "fputtc_nolock function", "_fputc_nolock function", "fputc_nolock function", "_fputtc_nolock function", "_fputwc_nolock function"]
-ms.assetid: c63eb3ad-58fa-46d0-9249-9c25f815eab9
---
# `_fputc_nolock`, `_fputwc_nolock`
-Writes a character to a stream without locking the thread.
+Writes a character to a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/fread-nolock-s2.md b/docs/c-runtime-library/reference/fread-nolock-s2.md
index e2d09bd776..f471494eae 100644
--- a/docs/c-runtime-library/reference/fread-nolock-s2.md
+++ b/docs/c-runtime-library/reference/fread-nolock-s2.md
@@ -1,17 +1,16 @@
---
-description: "Learn more about: _fread_nolock_s"
title: "_fread_nolock_s2"
+description: "Learn more about: _fread_nolock_s"
ms.date: "4/2/2020"
api_name: ["_fread_nolock_s", "_o__fread_nolock_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_fread_nolock_s", "stdio/_fread_nolock_s"]
-ms.assetid: 5badb9ab-11df-4e17-8162-30bda2a4572e
---
# `_fread_nolock_s`
-Reads data from a stream, without locking other threads. This version of [`fread_nolock`](fread-nolock.md) has security enhancements, as described in [Security features in the CRT](../security-features-in-the-crt.md).
+Reads data from a stream without locking. This version of [`fread_nolock`](fread-nolock.md) has security enhancements, as described in [Security features in the CRT](../security-features-in-the-crt.md).
## Syntax
diff --git a/docs/c-runtime-library/reference/fread-nolock.md b/docs/c-runtime-library/reference/fread-nolock.md
index 33a87a6e60..44f32e0cac 100644
--- a/docs/c-runtime-library/reference/fread-nolock.md
+++ b/docs/c-runtime-library/reference/fread-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _fread_nolock"
title: "_fread_nolock"
+description: "Learn more about: _fread_nolock"
ms.date: "4/2/2020"
api_name: ["_fread_nolock", "_o__fread_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_fread_nolock", "fread_nolock"]
helpviewer_keywords: ["reading data [C++], from input streams", "data [C++], reading from input stream", "fread_nolock function", "_fread_nolock function", "streams [C++], reading data from"]
-ms.assetid: 60e4958b-1097-46f5-a77b-94af5e7dba40
---
# `_fread_nolock`
-Reads data from a stream, without locking other threads.
+Reads data from a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/freopen-wfreopen.md b/docs/c-runtime-library/reference/freopen-wfreopen.md
index 7f4f99c2dc..79b74adb3f 100644
--- a/docs/c-runtime-library/reference/freopen-wfreopen.md
+++ b/docs/c-runtime-library/reference/freopen-wfreopen.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: freopen, _wfreopen"
title: "freopen, _wfreopen"
+description: "Learn more about: freopen, _wfreopen"
ms.date: "2/23/2021"
api_name: ["freopen", "_wfreopen", "_o__wfreopen", "_o_freopen"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -141,4 +141,4 @@ This will go to the file 'freopen.out'
[`_fileno`](fileno.md)\
[`fopen`, `_wfopen`](fopen-wfopen.md)\
[`_open`, `_wopen`](open-wopen.md)\
-[`_setmode`](setmode.md)\
+[`_setmode`](setmode.md)
diff --git a/docs/c-runtime-library/reference/fseek-nolock-fseeki64-nolock.md b/docs/c-runtime-library/reference/fseek-nolock-fseeki64-nolock.md
index 093ec08bc1..9df36b8acd 100644
--- a/docs/c-runtime-library/reference/fseek-nolock-fseeki64-nolock.md
+++ b/docs/c-runtime-library/reference/fseek-nolock-fseeki64-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _fseek_nolock, _fseeki64_nolock"
title: "_fseek_nolock, _fseeki64_nolock"
+description: "Learn more about: _fseek_nolock, _fseeki64_nolock"
ms.date: "4/2/2020"
api_name: ["_fseek_nolock", "_fseeki64_nolock", "_o__fseek_nolock", "_o__fseeki64_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_fseek_nolock", "_fseeki64_nolock", "fseek_nolock", "fseeki64_nolock"]
helpviewer_keywords: ["_fseek_nolock function", "fseeki64_nolock function", "file pointers [C++], moving", "fseek_nolock function", "_fseeki64_nolock function", "seek file pointers"]
-ms.assetid: 2dd4022e-b715-462b-b935-837561605a02
---
# `_fseek_nolock`, `_fseeki64_nolock`
-Moves the file pointer to a specified location.
+Moves the file pointer to a specified location without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/fsopen-wfsopen.md b/docs/c-runtime-library/reference/fsopen-wfsopen.md
index c4d8acc125..5f2c003e22 100644
--- a/docs/c-runtime-library/reference/fsopen-wfsopen.md
+++ b/docs/c-runtime-library/reference/fsopen-wfsopen.md
@@ -1,14 +1,13 @@
---
description: "Learn more about: _fsopen, _wfsopen"
title: "_fsopen, _wfsopen"
-ms.date: "4/2/2020"
+ms.date: 4/27/2023
api_name: ["_wfsopen", "_fsopen", "_o__fsopen", "_o__wfsopen"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["wfsopen", "fsopen", "tfsopen", "_tfsopen", "_wfsopen", "_fsopen"]
helpviewer_keywords: ["opening files, streams", "fsopen function", "tfsopen function", "wfsopen function", "_fsopen function", "files [C++], opening", "_tfsopen function", "_wfsopen function", "file sharing [C++]"]
-ms.assetid: 5e4502ab-48a9-4bee-a263-ebac8d638dec
---
# `_fsopen`, `_wfsopen`
@@ -69,13 +68,20 @@ When a file is opened with the **"`a`"** or **"`a+`"** access type, all write op
|---|---|
| **`t`** | Opens a file in text (translated) mode. In this mode, carriage return-line feed (CR-LF) combinations are translated into single line feeds (LF) on input and LF characters are translated to CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading or reading/writing, **`_fsopen`** checks for a CTRL+Z at the end of the file and removes it, if possible. It's removed because using [`fseek`](fseek-fseeki64.md) and [`ftell`](ftell-ftelli64.md) to move within a file that ends with a CTRL+Z might cause [`fseek`](fseek-fseeki64.md) to behave improperly near the end of the file. |
| **`b`** | Opens a file in binary (untranslated) mode; the above translations are suppressed. |
-| **`S`** | Specifies that caching is optimized for, but not restricted to, sequential access from disk. |
+| **`D`** | Specifies a temporary file that's deleted when the last file pointer to it is closed. |
| **`R`** | Specifies that caching is optimized for, but not restricted to, random access from disk. |
-| **`T`** | Specifies a file as temporary. If possible, it isn't flushed to disk. |
-| **`D`** | Specifies a file as temporary. It's deleted when the last file pointer is closed. |
+| **`S`** | Specifies that caching is optimized for, but not restricted to, sequential access from disk. |
+| **`T`** | Specifies a file that isn't written to disk unless memory pressure requires it. |
If **`t`** or **`b`** isn't given in *`mode`*, the translation mode is defined by the default-mode variable **`_fmode`**. If **`t`** or **`b`** is prefixed to the argument, the function fails and returns `NULL`. For a discussion of text and binary modes, see [Text and binary mode file I/O](../text-and-binary-mode-file-i-o.md).
+Regarding `T` and `D`:
+- `T` avoids writing the file to disk as long as memory pressure doesn't require it. For more information, see `FILE_ATTRIBUTE_TEMPORARY` in [File attribute constants](/windows/win32/fileio/file-attribute-constants), and also this blog post [It's only temporary](/archive/blogs/larryosterman/its-only-temporary).
+- `D` specifies a regular file that is written to disk. The difference is that it's automatically deleted when it's closed.
+You can combine `TD` to get both semantics.
+
+`_fsopen` and `_wfsopen` are Microsoft-specific variants of [`fopen`](fopen-wfopen.md). They aren't part of the ANSI standard. For a more portable and secure function, if you don't require file sharing, consider [`_wfopen_s` or `fopen_s`](fopen-s-wfopen-s.md).
+
The argument *`shflag`* is a constant expression consisting of one of the following manifest constants, defined in `Share.h`.
| Term | Definition |
diff --git a/docs/c-runtime-library/reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32.md b/docs/c-runtime-library/reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32.md
index c89869526a..41ce094bcc 100644
--- a/docs/c-runtime-library/reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32.md
+++ b/docs/c-runtime-library/reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32.md
@@ -22,11 +22,11 @@ int _fstat(
);
int _fstat32(
int fd,
- struct __stat32 *buffer
+ struct _stat32 *buffer
);
int _fstat64(
int fd,
- struct __stat64 *buffer
+ struct _stat64 *buffer
);
int _fstati64(
int fd,
@@ -73,7 +73,7 @@ If *`fd`* refers to a device, the **`st_atime`**, **`st_ctime`**, **`st_mtime`**
Because `Stat.h` uses the [`_dev_t`](../standard-types.md) type, which is defined in `Types.h`, you must include `Types.h` before `Stat.h` in your code.
-**`_fstat64`**, which uses the `__stat64` structure, allows file-creation dates to be expressed up through 23:59:59, December 31, 3000, UTC; whereas the other functions only represent dates through 23:59:59 January 18, 2038, UTC. The lower bound of the date range for all these functions is Midnight, January 1, 1970.
+**`_fstat64`**, which uses the `_stat64` structure, allows file-creation dates to be expressed up through 23:59:59, December 31, 3000, UTC; whereas the other functions only represent dates through 23:59:59 January 18, 2038, UTC. The lower bound of the date range for all these functions is Midnight, January 1, 1970.
Variations of these functions support 32-bit or 64-bit time types and 32-bit or 64-bit file lengths. The first numerical suffix (**`32`** or **`64`**) indicates the size of the time type used; the second suffix is either **`i32`** or **`i64`**, indicating whether the file size is represented as a 32-bit or 64-bit integer.
diff --git a/docs/c-runtime-library/reference/ftell-nolock-ftelli64-nolock.md b/docs/c-runtime-library/reference/ftell-nolock-ftelli64-nolock.md
index 1ea776edcf..7b8c51b173 100644
--- a/docs/c-runtime-library/reference/ftell-nolock-ftelli64-nolock.md
+++ b/docs/c-runtime-library/reference/ftell-nolock-ftelli64-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _ftell_nolock, _ftelli64_nolock"
title: "_ftell_nolock, _ftelli64_nolock"
+description: "Learn more about: _ftell_nolock, _ftelli64_nolock"
ms.date: "4/2/2020"
api_name: ["_ftelli64_nolock", "_ftell_nolock", "_o__ftell_nolock", "_o__ftelli64_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_ftelli64_nolock", "ftelli64_nolock", "ftell_nolock", "_ftell_nolock"]
helpviewer_keywords: ["ftelli64_nolock function", "_ftelli64_nolock function", "_ftell_nolock function", "ftell_nolock function", "file pointers [C++], getting current position"]
-ms.assetid: 84e68b0a-32f8-4c4a-90ad-3f2387685ede
---
# `_ftell_nolock`, `_ftelli64_nolock`
-Gets the current position of a file pointer, without locking the thread.
+Gets the current position of a file pointer without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/fwide.md b/docs/c-runtime-library/reference/fwide.md
index f21511e106..71113cfe48 100644
--- a/docs/c-runtime-library/reference/fwide.md
+++ b/docs/c-runtime-library/reference/fwide.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: fwide"
title: "fwide"
-ms.date: "11/04/2016"
+description: "Learn more about: fwide"
+ms.date: 11/04/2016
api_name: ["fwide"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["fwide"]
helpviewer_keywords: ["fwide function"]
-ms.assetid: a4641f5b-d74f-4946-95d5-53a64610d28d
---
# `fwide`
@@ -19,7 +18,7 @@ Unimplemented.
```C
int fwide(
FILE *stream,
- int mode;
+ int mode
);
```
diff --git a/docs/c-runtime-library/reference/fwrite-nolock.md b/docs/c-runtime-library/reference/fwrite-nolock.md
index 524a968125..1f72d29198 100644
--- a/docs/c-runtime-library/reference/fwrite-nolock.md
+++ b/docs/c-runtime-library/reference/fwrite-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _fwrite_nolock"
title: "_fwrite_nolock"
+description: "Learn more about: _fwrite_nolock"
ms.date: "4/2/2020"
api_name: ["_fwrite_nolock", "_o__fwrite_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_fwrite_nolock", "fwrite_nolock"]
helpviewer_keywords: ["fwrite_nolock function", "streams, writing data to", "_fwrite_nolock function"]
-ms.assetid: 2b4ec6ce-742e-4615-8407-44a0a18ec1d7
---
# `_fwrite_nolock`
-Writes data to a stream, without locking the thread.
+Writes data to a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/get-timezone.md b/docs/c-runtime-library/reference/get-timezone.md
index 017c4d09ca..9b273ddf65 100644
--- a/docs/c-runtime-library/reference/get-timezone.md
+++ b/docs/c-runtime-library/reference/get-timezone.md
@@ -33,7 +33,7 @@ Zero if successful or an `errno` value if an error occurs.
## Remarks
-The **`_get_timezone`** function retrieves the difference in seconds between UTC and local time as an integer. The default value is 28,800 seconds, for Pacific Standard Time (eight hours behind UTC).
+The **`_get_timezone`** function retrieves the difference in seconds between UTC and local time as an integer. The default value is 28,800 seconds, for Pacific Standard Time (eight hours behind UTC). If you don't want the default value, call _tzset first to initialize the timezone.
If *`seconds`* is `NULL`, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, this function sets `errno` to `EINVAL` and returns `EINVAL`.
diff --git a/docs/c-runtime-library/reference/getc-nolock-getwc-nolock.md b/docs/c-runtime-library/reference/getc-nolock-getwc-nolock.md
index d825ec6c7b..f2ebc85b2a 100644
--- a/docs/c-runtime-library/reference/getc-nolock-getwc-nolock.md
+++ b/docs/c-runtime-library/reference/getc-nolock-getwc-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _getc_nolock, _getwc_nolock"
title: "_getc_nolock, _getwc_nolock"
+description: "Learn more about: _getc_nolock, _getwc_nolock"
ms.date: "4/2/2020"
api_name: ["_getc_nolock", "_getwc_nolock", "_o__getc_nolock", "_o__getwc_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["getc_nolock", "_gettc_nolock", "_getc_nolock", "getwc_nolock", "gettc_nolock", "_getwc_nolock"]
helpviewer_keywords: ["characters, reading", "_getc_nolock function", "_getwc_nolock function", "getwc_nolock function", "streams, reading characters from", "reading characters from streams", "getc_nolock function", "gettc_nolock function", "_gettc_nolock function"]
-ms.assetid: eb37b272-e177-41c9-b077-12ce7ffd3b88
---
# `_getc_nolock`, `_getwc_nolock`
-Reads a character from a stream.
+Reads a character from a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/getch-nolock-getwch-nolock.md b/docs/c-runtime-library/reference/getch-nolock-getwch-nolock.md
index 8c9b4a8a32..61bf1a4ace 100644
--- a/docs/c-runtime-library/reference/getch-nolock-getwch-nolock.md
+++ b/docs/c-runtime-library/reference/getch-nolock-getwch-nolock.md
@@ -1,6 +1,6 @@
---
title: "_getch_nolock, _getwch_nolock"
-description: "API reference for _getch_nolock, and _getwch_nolock; which get a character from the console without echo and without locking the thread."
+description: "Learn more about: _getch_nolock, _getwch_nolock"
ms.date: "4/2/2020"
api_name: ["_getwch_nolock", "_getch_nolock", "_o__getch_nolock", "_o__getwch_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-conio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_getch_nolock", "getwch_nolock", "getch_nolock", "_getwch_nolock", "_gettch_nolock", "gettch_nolock"]
helpviewer_keywords: ["characters, getting from console", "_getwch_nolock function", "_getch_nolock function", "getwch_nolock function", "_gettch_nolock function", "console, reading from", "getch_nolock function", "gettch_nolock function"]
-ms.assetid: 9d248546-26ca-482c-b0c6-55812a987e83
---
# `_getch_nolock`, `_getwch_nolock`
-Gets a character from the console without echo and without locking the thread.
+Gets a character from the console without echo and without locking.
> [!IMPORTANT]
> This API cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported in Universal Windows Platform apps](../../cppcx/crt-functions-not-supported-in-universal-windows-platform-apps.md).
diff --git a/docs/c-runtime-library/reference/getchar-nolock-getwchar-nolock.md b/docs/c-runtime-library/reference/getchar-nolock-getwchar-nolock.md
index aaf8bcf23a..2aba163479 100644
--- a/docs/c-runtime-library/reference/getchar-nolock-getwchar-nolock.md
+++ b/docs/c-runtime-library/reference/getchar-nolock-getwchar-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _getchar_nolock, _getwchar_nolock"
title: "_getchar_nolock, _getwchar_nolock"
+description: "Learn more about: _getchar_nolock, _getwchar_nolock"
ms.date: "11/04/2016"
api_name: ["_getchar_nolock", "_getwchar_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["getwchar_nolock", "_getwchar_nolock", "_getchar_nolock", "getchar_nolock"]
helpviewer_keywords: ["_getwchar_nolock function", "getwchar_nolock function", "characters, reading", "_getchar_nolock function", "getchar_nolock function", "standard input, reading from"]
-ms.assetid: dc49ba60-0647-4ae9-aa9a-a0618b1666de
---
# `_getchar_nolock`, `_getwchar_nolock`
-Reads a character from standard input.
+Reads a character from the standard input without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/getche-nolock-getwche-nolock.md b/docs/c-runtime-library/reference/getche-nolock-getwche-nolock.md
index 821f722335..c9c6b7ad6f 100644
--- a/docs/c-runtime-library/reference/getche-nolock-getwche-nolock.md
+++ b/docs/c-runtime-library/reference/getche-nolock-getwche-nolock.md
@@ -1,6 +1,6 @@
---
title: "_getche_nolock, _getwche_nolock"
-description: "API reference for _getche_nolock, and _getwche_nolock; which gets a character from the console, with echo and without locking the thread."
+description: "Learn more about: _getche_nolock, _getwche_nolock"
ms.date: "4/2/2020"
api_name: ["_getche_nolock", "_getwche_nolock", "_o__getche_nolock", "_o__getwche_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-conio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_getche_nolock", "_gettche_nolock", "_getwche_nolock", "getche_nolock", "getwche_nolock", "gettche_nolock"]
helpviewer_keywords: ["characters, getting from console", "_gettche_nolock function", "getwche_nolock function", "_getche_nolock function", "getche_nolock function", "console, reading from", "_getwche_nolock function", "gettche_nolock function"]
-ms.assetid: 9e853ad4-4d8a-4442-9ae5-da4b434f0b8c
---
# `_getche_nolock`, `_getwche_nolock`
-Gets a character from the console, with echo and without locking the thread.
+Gets a character from the console with echo and without locking.
> [!IMPORTANT]
> This API cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported in Universal Windows Platform apps](../../cppcx/crt-functions-not-supported-in-universal-windows-platform-apps.md).
diff --git a/docs/c-runtime-library/reference/getdcwd-nolock-wgetdcwd-nolock.md b/docs/c-runtime-library/reference/getdcwd-nolock-wgetdcwd-nolock.md
index 1ee8358edb..b186869ad1 100644
--- a/docs/c-runtime-library/reference/getdcwd-nolock-wgetdcwd-nolock.md
+++ b/docs/c-runtime-library/reference/getdcwd-nolock-wgetdcwd-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _getdcwd_nolock, _wgetdcwd_nolock"
title: "_getdcwd_nolock, _wgetdcwd_nolock"
+description: "Learn more about: _getdcwd_nolock, _wgetdcwd_nolock"
ms.date: "11/04/2016"
api_name: ["_wgetdcwd_nolock", "_getdcwd_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_wgetdcwd_nolock", "tgetdcwd_nolock", "wgetdcwd_nolock", "_getdcwd_nolock", "_tgetdcwd_nolock", "getdcwd_nolock"]
helpviewer_keywords: ["getdcwd_nolock function", "_tgetdcwd_nolock function", "working directory", "tgetdcwd_nolock function", "_getdcwd_nolock function", "current working directory", "wgetdcwd_nolock function", "_wgetdcwd_nolock function", "directories [C++], current working"]
-ms.assetid: d9bdf712-43f8-4173-8f9a-844e82beaa97
---
# `_getdcwd_nolock`, `_wgetdcwd_nolock`
diff --git a/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md b/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md
index 4baf83e371..1d0656b3f7 100644
--- a/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md
+++ b/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md
@@ -1,7 +1,7 @@
---
title: "gmtime, _gmtime32, _gmtime64"
description: "API reference for gmtime, _gmtime32, and _gmtime64, which convert a time_t value."
-ms.date: "10/27/2020"
+ms.date: 02/23/2024
api_name: ["_gmtime32", "gmtime", "_gmtime64", "_o__gmtime32", "_o__gmtime64"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-time-l1-1-0.dll"]
api_type: ["DLLExport"]
@@ -54,9 +54,6 @@ These functions validate their parameters. If *`sourceTime`* is a `NULL` pointer
The **`_gmtime32`** function breaks down the *`sourceTime`* value and stores it in a statically allocated structure of type `tm`, defined in `TIME.H`. The value of *`sourceTime`* is typically obtained from a call to the [`time`](time-time32-time64.md) function.
-> [!NOTE]
-> In most cases, the target environment tries to determine whether daylight savings time is in effect. The C run-time library assumes that the United States rules for implementing the calculation of Daylight Saving Time (DST) are used.
-
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
## Requirements
diff --git a/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md b/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md
index 7db288694f..9151701714 100644
--- a/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md
+++ b/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md
@@ -1,7 +1,7 @@
---
description: "Learn more about: gmtime_s, _gmtime32_s, _gmtime64_s"
title: "gmtime_s, _gmtime32_s, _gmtime64_s"
-ms.date: "4/2/2020"
+ms.date: 02/23/2024
api_name: ["_gmtime32_s", "gmtime_s", "_gmtime64_s", "_o__gmtime32_s", "_o__gmtime64_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-time-l1-1-0.dll"]
api_type: ["DLLExport"]
@@ -56,9 +56,6 @@ The first two error conditions invoke the invalid parameter handler, as describe
The **`_gmtime32_s`** function breaks down the *`sourceTime`* value and stores it in a structure of type `tm`, defined in `Time.h`. The address of the structure is passed in *`tmDest`*. The value of *`sourceTime`* is often obtained from a call to the [`time`](time-time32-time64.md) function.
-> [!NOTE]
-> The target environment should try to determine whether daylight savings time is in effect. The C run-time library assumes the United States rules for implementing the calculation of daylight saving time .
-
Each of the structure fields is of type **`int`**, as shown in the following table.
| Field | Description |
diff --git a/docs/c-runtime-library/reference/heapchk.md b/docs/c-runtime-library/reference/heapchk.md
index 589d119aef..4e77c83690 100644
--- a/docs/c-runtime-library/reference/heapchk.md
+++ b/docs/c-runtime-library/reference/heapchk.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _heapchk"
title: "_heapchk"
+description: "Learn more about: _heapchk"
ms.date: "4/2/2020"
api_name: ["_heapchk", "_o__heapchk"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-heap-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_heapchk", "heapchk"]
helpviewer_keywords: ["debugging [CRT], heap-related problems", "consistency checking of heaps", "heapchk function", "heaps, checking consistency", "_heapchk function"]
-ms.assetid: 859619a5-1e35-4f02-9e09-11d9fa266ec0
---
# `_heapchk`
@@ -36,7 +35,7 @@ In addition, if an error occurs, **`_heapchk`** sets `errno` to `ENOSYS`.
## Remarks
-The **`_heapchk`** function helps debug heap-related problems by checking for minimal consistency of the heap. If the operating system doesn't support **`_heapchk`**(for example, Windows 98), the function returns `_HEAPOK` and sets `errno` to `ENOSYS`.
+The **`_heapchk`** function helps debug heap-related problems by checking for minimal consistency of the heap. If the operating system doesn't support **`_heapchk`** (for example, Windows 98), the function returns `_HEAPOK` and sets `errno` to `ENOSYS`.
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
diff --git a/docs/c-runtime-library/reference/heapmin.md b/docs/c-runtime-library/reference/heapmin.md
index ffee2908c1..f5f5e5671a 100644
--- a/docs/c-runtime-library/reference/heapmin.md
+++ b/docs/c-runtime-library/reference/heapmin.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _heapmin"
title: "_heapmin"
+description: "Learn more about: _heapmin"
ms.date: "4/2/2020"
api_name: ["_heapmin", "_o__heapmin"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-heap-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_heapmin", "heapmin"]
helpviewer_keywords: ["heap memory", "minimizing heaps", "memory, releasing", "heaps, releasing unused memory", "_heapmin function", "heapmin function"]
-ms.assetid: c0bccdf6-2d14-4d7b-a7ff-d6a17bdb410f
---
# `_heapmin`
@@ -28,7 +27,7 @@ For more information about this and other return codes, see [`errno`, `_doserrno
## Remarks
-The **`_heapmin`** function minimizes the heap by releasing unused heap memory to the operating system. If the operating system doesn't support **`_heapmin`**(for example, Windows 98), the function returns -1 and sets `errno` to `ENOSYS`.
+The **`_heapmin`** function minimizes the heap by releasing unused heap memory to the operating system. If the operating system doesn't support **`_heapmin`** (for example, Windows 98), the function returns -1 and sets `errno` to `ENOSYS`.
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
diff --git a/docs/c-runtime-library/reference/initterm-initterm-e.md b/docs/c-runtime-library/reference/initterm-initterm-e.md
index 27ef43bc02..3063706706 100644
--- a/docs/c-runtime-library/reference/initterm-initterm-e.md
+++ b/docs/c-runtime-library/reference/initterm-initterm-e.md
@@ -25,8 +25,8 @@ void __cdecl _initterm(
);
int __cdecl _initterm_e(
- PVFV *,
- PVFV *
+ PIFV *,
+ PIFV *
);
```
diff --git a/docs/c-runtime-library/reference/islower-iswlower-islower-l-iswlower-l.md b/docs/c-runtime-library/reference/islower-iswlower-islower-l-iswlower-l.md
index 02dded213e..f95d12c979 100644
--- a/docs/c-runtime-library/reference/islower-iswlower-islower-l-iswlower-l.md
+++ b/docs/c-runtime-library/reference/islower-iswlower-islower-l-iswlower-l.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: islower, iswlower, _islower_l, _iswlower_l"
title: "islower, iswlower, _islower_l, _iswlower_l"
-ms.date: "4/2/2020"
+description: "Learn more about: islower, iswlower, _islower_l, _iswlower_l"
+ms.date: 4/2/2020
api_name: ["iswlower", "_islower_l", "islower", "_iswlower_l", "_o_islower", "_o_iswlower"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-string-l1-1-0.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_istlower", "islower", "_ismbclower_l", "_liswlower_l", "_istlower_l", "_iswlower_l", "_islower _l", "_islower_l", "iswlower"]
helpviewer_keywords: ["_islower _l function", "_ismbclower_l function", "islower function", "_iswlower_l function", "_liswlower_l function", "_istlower_l function", "istlower function", "_istlower function", "iswlower function", "_islower_l function"]
-ms.assetid: fcc3b70a-2b47-45fd-944d-e5c1942e6457
---
# `islower`, `iswlower`, `_islower_l`, `_iswlower_l`
@@ -54,7 +53,7 @@ The behavior of **`islower`** and **`_islower_l`** is undefined if *`c`* isn't E
| TCHAR.H routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
| `_istlower` | **`islower`** | [`_ismbclower`](ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md) | **`iswlower`** |
-| **`_istlower_l`** | `_islower _l` | [`_ismbclower_l`](ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md) | **`_liswlower_l`** |
+| **`_istlower_l`** | `_islower_l` | [`_ismbclower_l`](ismbclower-ismbclower-l-ismbcupper-ismbcupper-l.md) | **`_liswlower_l`** |
## Remarks
@@ -64,10 +63,10 @@ By default, this function's global state is scoped to the application. To change
| Routine | Required header |
|---|---|
-| **`islower`** | \ |
-| **`iswlower`** | \ or \ |
-| **`_islower_l`** | \ |
-| **`_swlower_l`** | \ or \ |
+| **`islower`** | `` |
+| **`iswlower`** | `` or `` |
+| **`_islower_l`** | `` |
+| **`_swlower_l`** | `` or `` |
For more compatibility information, see [Compatibility](../compatibility.md).
diff --git a/docs/c-runtime-library/reference/itoa-itow.md b/docs/c-runtime-library/reference/itoa-itow.md
index 48046135b6..1f03714208 100644
--- a/docs/c-runtime-library/reference/itoa-itow.md
+++ b/docs/c-runtime-library/reference/itoa-itow.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_itoa", "_ltoa", "_ultoa", "_i64toa", "_ui64toa", "_itow", "_ltow", "_ultow", "_i64tow", "_ui64tow", "itoa", "ltoa", "ultoa", "i64toa", "ui64toa", "itow", "ltow", "ultow", "i64tow", "ui64tow", "itot", "_itot", "ltot", "_ltot", "ultot", "_ultot", "i64tot", "_i64tot", "ui64tot", "_ui64tot", "_MAX_ITOSTR_BASE16_COUNT", "_MAX_ITOSTR_BASE10_COUNT", "_MAX_ITOSTR_BASE8_COUNT", "_MAX_ITOSTR_BASE2_COUNT", "_MAX_LTOSTR_BASE16_COUNT", "_MAX_LTOSTR_BASE10_COUNT", "_MAX_LTOSTR_BASE8_COUNT", "_MAX_LTOSTR_BASE2_COUNT", "_MAX_ULTOSTR_BASE16_COUNT", "_MAX_ULTOSTR_BASE10_COUNT", "_MAX_ULTOSTR_BASE8_COUNT", "_MAX_ULTOSTR_BASE2_COUNT", "_MAX_I64TOSTR_BASE16_COUNT", "_MAX_I64TOSTR_BASE10_COUNT", "_MAX_I64TOSTR_BASE8_COUNT", "_MAX_I64TOSTR_BASE2_COUNT", "_MAX_U64TOSTR_BASE16_COUNT", "_MAX_U64TOSTR_BASE10_COUNT", "_MAX_U64TOSTR_BASE8_COUNT", "_MAX_U64TOSTR_BASE2_COUNT"]
helpviewer_keywords: ["_itot function", "ui64toa function", "_ui64toa function", "converting integers", "itot function", "_i64tow function", "_i64toa function", "_itow function", "ui64tow function", "integers, converting", "itoa function", "_ui64tow function", "i64tow function", "itow function", "i64toa function", "converting numbers, to strings", "_itoa function"]
-ms.assetid: 46592a00-77bb-4e73-98c0-bf629d96cea6
---
# `itoa`, `_itoa`, `ltoa`, `_ltoa`, `ultoa`, `_ultoa`, `_i64toa`, `_ui64toa`, `_itow`, `_ltow`, `_ultow`, `_i64tow`, `_ui64tow`
@@ -137,7 +136,7 @@ This example uses a conversion count macro to define a buffer large enough to co
int main()
{
wchar_t buffer[_MAX_U64TOSTR_BASE2_COUNT];
- std:wcout << _ui64tow(0xFFFFFFFFFFFFFFFFull, buffer, 2) << std::endl;
+ std::wcout << _ui64tow(0xFFFFFFFFFFFFFFFFull, buffer, 2) << std::endl;
}
```
diff --git a/docs/c-runtime-library/reference/kbhit.md b/docs/c-runtime-library/reference/kbhit.md
index e4f1f9cfb7..3d89e65caa 100644
--- a/docs/c-runtime-library/reference/kbhit.md
+++ b/docs/c-runtime-library/reference/kbhit.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _kbhit"
title: "_kbhit"
+description: "Learn more about: _kbhit"
ms.date: "4/2/2020"
api_name: ["_kbhit", "_o__kbhit"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_kbhit", "conio/_kbhit"]
helpviewer_keywords: ["keyboard input", "user input, checking for keyboard", "kbhit function", "console", "console, checking", "keyboards, keyboard input", "_kbhit function", "keyboards, checking input"]
-ms.assetid: e82a1cc9-bbec-4150-b678-a7e433220fe4
---
# `_kbhit`
@@ -20,7 +19,6 @@ Checks the console for keyboard input.
## Syntax
```C
-
int _kbhit( void );
```
diff --git a/docs/c-runtime-library/reference/log-logf-log10-log10f.md b/docs/c-runtime-library/reference/log-logf-log10-log10f.md
index 475f466870..4ff277f7b0 100644
--- a/docs/c-runtime-library/reference/log-logf-log10-log10f.md
+++ b/docs/c-runtime-library/reference/log-logf-log10-log10f.md
@@ -122,9 +122,9 @@ Log base 2 of 65536.000000 is 16.000000
## See also
-[Math and floating-point support](../floating-point-support.md) \
-[`exp`, `expf`, `expl`](exp-expf.md) \
-[`_matherr`](matherr.md) \
-[`pow`, `powf`, `powl`](pow-powf-powl.md) \
-[`_CIlog`](../cilog.md) \
-[`_CIlog10`](../cilog10.md)\
+[Math and floating-point support](../floating-point-support.md)\
+[`exp`, `expf`, `expl`](exp-expf.md)\
+[`_matherr`](matherr.md)\
+[`pow`, `powf`, `powl`](pow-powf-powl.md)\
+[`_CIlog`](../cilog.md)\
+[`_CIlog10`](../cilog10.md)
diff --git a/docs/c-runtime-library/reference/longjmp.md b/docs/c-runtime-library/reference/longjmp.md
index e94b1110c1..da78b65d11 100644
--- a/docs/c-runtime-library/reference/longjmp.md
+++ b/docs/c-runtime-library/reference/longjmp.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: longjmp"
title: "longjmp"
+description: "Learn more about: longjmp"
ms.date: "1/14/2021"
api_name: ["longjmp"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "ntoskrnl.exe"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["longjmp"]
helpviewer_keywords: ["restoring stack environment and execution locale", "longjmp function"]
-ms.assetid: 0e13670a-5130-45c1-ad69-6862505b7a2f
---
# `longjmp`
@@ -75,5 +74,5 @@ See the example for [`_fpreset`](fpreset.md).
## See also
-[Process and environment control](../process-and-environment-control.md)
+[Process and environment control](../process-and-environment-control.md)\
[`setjmp`](setjmp.md)
diff --git a/docs/c-runtime-library/reference/malloca.md b/docs/c-runtime-library/reference/malloca.md
index 9953a91657..56b67ffeb9 100644
--- a/docs/c-runtime-library/reference/malloca.md
+++ b/docs/c-runtime-library/reference/malloca.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: _malloca"
title: "_malloca"
-ms.date: "11/04/2016"
+description: "Learn more about: _malloca"
+ms.date: 11/04/2016
api_name: ["_malloca"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
@@ -38,7 +38,7 @@ If *`size`* is greater than `_ALLOCA_S_THRESHOLD`, then **`_malloca`** attempts
There are restrictions to explicitly calling **`_malloca`** in an exception handler (EH). EH routines that run on x86-class processors operate in their own memory frame: They perform their tasks in memory space that isn't based on the current location of the stack pointer of the enclosing function. The most common implementations include Windows NT structured exception handling (SEH) and C++ catch clause expressions. Therefore, explicitly calling **`_malloca`** in any of the following scenarios results in program failure during the return to the calling EH routine:
-- Windows SEH exception filter expression: **`__except`** (`_malloca ()` )
+- Windows SEH exception filter expression: **`__except`** (`_malloca ()`)
- Windows SEH final exception handler: **`__finally`** {`_malloca ()` }
diff --git a/docs/c-runtime-library/reference/mbbtype-mbbtype-l.md b/docs/c-runtime-library/reference/mbbtype-mbbtype-l.md
index abff8af776..d3e9461cbe 100644
--- a/docs/c-runtime-library/reference/mbbtype-mbbtype-l.md
+++ b/docs/c-runtime-library/reference/mbbtype-mbbtype-l.md
@@ -50,9 +50,9 @@ The locale to use.
|---|---|---|---|
| Any value except 1 | Valid single byte or lead byte | `_MBC_SINGLE` (0) | Single byte (0x20 - 0x7E, 0xA1 - 0xDF) |
| Any value except 1 | Valid single byte or lead byte | `_MBC_LEAD` (1) | Lead byte of multibyte character (0x81 - 0x9F, 0xE0 - 0xFC) |
-| Any value except 1 | Valid single-byte or lead byte | `_MBC_ILLEGAL`
(-1) | Invalid character (any value except 0x20 - 0x7E, 0xA1 - 0xDF, 0x81 - 0x9F, 0xE0 - 0xFC |
+| Any value except 1 | Valid single-byte or lead byte | `_MBC_ILLEGAL` (-1) | Invalid character: not single or lead (0x00 - 0x1F, 0x7F, 0x80, 0xA0, 0xFD, 0xFE, 0xFF) |
| 1 | Valid trail byte | `_MBC_TRAIL` (2) | Trailing byte of multibyte character (0x40 - 0x7E, 0x80 - 0xFC) |
-| 1 | Valid trail byte | `_MBC_ILLEGAL`
(-1) | Invalid character (any value except 0x20 - 0x7E, 0xA1 - 0xDF, 0x81 - 0x9F, 0xE0 - 0xFC |
+| 1 | Valid trail byte | `_MBC_ILLEGAL` (-1) | Invalid character: not trailing (0x00 - 0x3F, 0x7F, 0xFD, 0xFE, 0xFF) |
## Remarks
diff --git a/docs/c-runtime-library/reference/mbrtowc.md b/docs/c-runtime-library/reference/mbrtowc.md
index b8634e50a7..7c64576e18 100644
--- a/docs/c-runtime-library/reference/mbrtowc.md
+++ b/docs/c-runtime-library/reference/mbrtowc.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: mbrtowc"
title: "mbrtowc"
-ms.date: "4/2/2020"
+description: "Learn more about: mbrtowc"
+ms.date: 4/2/2020
api_name: ["mbrtowc", "_o_mbrtowc"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-convert-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["mbrtowc"]
helpviewer_keywords: ["mbrtowc function"]
-ms.assetid: a1e87fcc-6de0-4ca1-bf26-508d28490286
---
# `mbrtowc`
@@ -100,7 +99,7 @@ int Sample(char* szIn, wchar_t* wcOut, int nMax)
szLocal = setlocale(LC_ALL, "French_Canada.1252");
if (!szLocal)
{
- printf("The fuction setlocale(LC_ALL, \"French_Canada.1252\") failed!\n");
+ printf("The function setlocale(LC_ALL, \"French_Canada.1252\") failed!\n");
return 1;
}
@@ -110,7 +109,7 @@ int Sample(char* szIn, wchar_t* wcOut, int nMax)
// from a previous call to setlocale.
if (_setmbcp(_MB_CP_SBCS) == -1)
{
- printf("The fuction _setmbcp(_MB_CP_SBCS) failed!");
+ printf("The function _setmbcp(_MB_CP_SBCS) failed!");
return 1;
}
diff --git a/docs/c-runtime-library/reference/mbsnbset-s-mbsnbset-s-l.md b/docs/c-runtime-library/reference/mbsnbset-s-mbsnbset-s-l.md
index 903e87992a..9fa6a973f5 100644
--- a/docs/c-runtime-library/reference/mbsnbset-s-mbsnbset-s-l.md
+++ b/docs/c-runtime-library/reference/mbsnbset-s-mbsnbset-s-l.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: _mbsnbset_s, _mbsnbset_s_l"
title: "_mbsnbset_s, _mbsnbset_s_l"
-ms.date: "4/2/2020"
+description: "Learn more about: _mbsnbset_s, _mbsnbset_s_l"
+ms.date: 4/2/2020
api_name: ["_mbsnbset_s_l", "_mbsnbset_s", "_o__mbsnbset_s", "_o__mbsnbset_s_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["mbsnbset_s", "_mbsnbset_s_l", "_mbsnbset_s", "mbsnbset_s_l"]
helpviewer_keywords: ["tcsnset_s function", "mbsnbset_s function", "mbsnbset_s_l function", "_mbsnbset_s_l function", "_tcsnset_s_l function", "_mbsnbset_s function", "_tcsnset_s function", "tcsnset_s_l function"]
-ms.assetid: 811f92c9-cc31-4bbd-8017-2d1bfc6fb96f
---
# `_mbsnbset_s`, `_mbsnbset_s_l`
@@ -90,14 +89,14 @@ By default, this function's global state is scoped to the application. To change
| Tchar.h routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
| `_tcsnset_s` | `_strnset_s` | **`_mbsnbset_s`** | `_wcsnset_s` |
-| `_tcsnset_s_l` | `_strnset_s _l` | **`_mbsnbset_s_l`** | `_wcsnset_s_l` |
+| `_tcsnset_s_l` | `_strnset_s_l` | **`_mbsnbset_s_l`** | `_wcsnset_s_l` |
## Requirements
| Routine | Required header |
|---|---|
-| **`_mbsnbset_s`** | \ |
-| **`_mbsnbset_s_l`** | \ |
+| **`_mbsnbset_s`** | `` |
+| **`_mbsnbset_s_l`** | `` |
For more compatibility information, see [Compatibility](../compatibility.md).
diff --git a/docs/c-runtime-library/reference/memcpy-wmemcpy.md b/docs/c-runtime-library/reference/memcpy-wmemcpy.md
index 6f9ff121ff..4572322b81 100644
--- a/docs/c-runtime-library/reference/memcpy-wmemcpy.md
+++ b/docs/c-runtime-library/reference/memcpy-wmemcpy.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: memcpy, wmemcpy"
title: "memcpy, wmemcpy"
+description: "Learn more about: memcpy, wmemcpy"
ms.date: "1/14/2021"
api_name: ["memcpy", "wmemcpy"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "ntoskrnl.exe"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["wmemcpy", "memcpy"]
helpviewer_keywords: ["wmemcpy function", "memcpy function"]
-ms.assetid: 34abb90b-bffb-46dc-a2f3-a5e9940839d6
---
# `memcpy`, `wmemcpy`
@@ -49,14 +48,14 @@ The value of *`dest`*.
**`memcpy`** copies *`count`* bytes from *`src`* to *`dest`*; **`wmemcpy`** copies *`count`* wide characters. If the source and destination regions overlap, the behavior of **`memcpy`** is undefined. Use **`memmove`** to handle overlapping regions.
> [!IMPORTANT]
-> Make sure that the destination buffer is the same size or larger than the source buffer. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
+> Make sure that the destination buffer is large enough to accommodate the number of copied characters. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
> [!IMPORTANT]
> Because so many buffer overruns, and thus potential security exploits, have been traced to improper usage of **`memcpy`**, this function is listed among the "banned" functions by the Security Development Lifecycle (SDL). You may observe that some VC++ library classes continue to use **`memcpy`**. Furthermore, you may observe that the VC++ compiler optimizer sometimes emits calls to **`memcpy`**. The Visual C++ product is developed in accordance with the SDL process, and thus usage of this banned function has been closely evaluated. In the case of library use of it, the calls have been carefully scrutinized to ensure that buffer overruns will not be allowed through these calls. In the case of the compiler, sometimes certain code patterns are recognized as identical to the pattern of **`memcpy`**, and are thus replaced with a call to the function. In such cases, the use of **`memcpy`** is no more unsafe than the original instructions would have been; they have simply been optimized to a call to the performance-tuned **`memcpy`** function. Just as the use of "safe" CRT functions doesn't guarantee safety (they just make it harder to be unsafe), the use of "banned" functions doesn't guarantee danger (they just require greater scrutiny to ensure safety).
>
> Because **`memcpy`** usage by the VC++ compiler and libraries has been so carefully scrutinized, these calls are permitted within code that otherwise conforms with the SDL. **`memcpy`** calls introduced in application source code only conform with the SDL when that use has been reviewed by security experts.
-The **`memcpy`** and **`wmemcpy`** functions are only deprecated if the constant `_CRT_SECURE_DEPRECATE_MEMORY` is defined before the include statement, as in the example below:
+The **`memcpy`** and **`wmemcpy`** functions are only deprecated if the constant `_CRT_SECURE_DEPRECATE_MEMORY` is defined before the `#include` statement, as in the following examples:
```C
#define _CRT_SECURE_DEPRECATE_MEMORY
@@ -92,4 +91,4 @@ See [`memmove`](memmove-wmemmove.md) for a sample of how to use **`memcpy`**.
[`memmove`, `wmemmove`](memmove-wmemmove.md)\
[`memset`, `wmemset`](memset-wmemset.md)\
[`strcpy_s`, `wcscpy_s`, `_mbscpy_s`](strcpy-s-wcscpy-s-mbscpy-s.md)\
-[`strncpy_s`, `_strncpy_s_l`, `wcsncpy_s`, `_wcsncpy_s_l`, `_mbsncpy_s`, `_mbsncpy_s_l`](strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md)\
+[`strncpy_s`, `_strncpy_s_l`, `wcsncpy_s`, `_wcsncpy_s_l`, `_mbsncpy_s`, `_mbsncpy_s_l`](strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md)
diff --git a/docs/c-runtime-library/reference/memmove-wmemmove.md b/docs/c-runtime-library/reference/memmove-wmemmove.md
index 4cce4c066c..00c3f732e4 100644
--- a/docs/c-runtime-library/reference/memmove-wmemmove.md
+++ b/docs/c-runtime-library/reference/memmove-wmemmove.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: memmove, wmemmove"
title: "memmove, wmemmove"
+description: "Learn more about: memmove, wmemmove"
ms.date: "1/14/2021"
api_name: ["memmove", "wmemmove"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ntdll.dll", "ucrtbase.dll", "ntoskrnl.exe"]
@@ -47,9 +47,9 @@ The value of *`dest`*.
Copies *`count`* bytes (**`memmove`**) or characters (**`wmemmove`**) from *`src`* to *`dest`*. If some portions of the source and the destination regions overlap, both functions ensure that the original source bytes in the overlapping region are copied before being overwritten.
-**Security Note** Make sure that the destination buffer is the same size or larger than the source buffer. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
+**Security Note** Make sure that the destination buffer is large enough to accommodate the number of moved characters. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
-The **`memmove`** and **`wmemmove`** functions will only be deprecated if the constant `_CRT_SECURE_DEPRECATE_MEMORY` is defined before the inclusion statement in order for the functions to be deprecated, such as in the example below:
+The **`memmove`** and **`wmemmove`** functions are only deprecated if the constant `_CRT_SECURE_DEPRECATE_MEMORY` is defined before the `#include` statement, as shown in the following example:
```C
#define _CRT_SECURE_DEPRECATE_MEMORY
@@ -114,4 +114,4 @@ New string: aaaabb
[`_memccpy`](memccpy.md)\
[`memcpy`, `wmemcpy`](memcpy-wmemcpy.md)\
[`strcpy`, `wcscpy`, `_mbscpy`](strcpy-wcscpy-mbscpy.md)\
-[`strncpy`, `_strncpy_l`, `wcsncpy`, `_wcsncpy_l`, `_mbsncpy`, `_mbsncpy_l`](strncpy-strncpy-l-wcsncpy-wcsncpy-l-mbsncpy-mbsncpy-l.md)\
+[`strncpy`, `_strncpy_l`, `wcsncpy`, `_wcsncpy_l`, `_mbsncpy`, `_mbsncpy_l`](strncpy-strncpy-l-wcsncpy-wcsncpy-l-mbsncpy-mbsncpy-l.md)
diff --git a/docs/c-runtime-library/reference/mkdir-wmkdir.md b/docs/c-runtime-library/reference/mkdir-wmkdir.md
index 43a9a54ba6..f01bf458e6 100644
--- a/docs/c-runtime-library/reference/mkdir-wmkdir.md
+++ b/docs/c-runtime-library/reference/mkdir-wmkdir.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _mkdir, _wmkdir"
title: "_mkdir, _wmkdir"
+description: "Learn more about: _mkdir, _wmkdir"
ms.date: "4/2/2020"
api_name: ["_wmkdir", "_mkdir", "_o__mkdir", "_o__wmkdir"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-filesystem-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_mkdir", "tmkdir", "_tmkdir", "wmkdir", "_wmkdir"]
helpviewer_keywords: ["_wmkdir function", "folders [C++], creating", "wmkdir function", "directories [C++], creating", "mkdir function", "tmkdir function", "_mkdir function", "_tmkdir function"]
-ms.assetid: 7f22d01d-63a5-4712-a6e7-d34878b2d840
---
# `_mkdir`, `_wmkdir`
@@ -17,7 +16,6 @@ Creates a new directory.
## Syntax
```C
-
int _mkdir(
const char *dirname
);
diff --git a/docs/c-runtime-library/reference/msize-dbg.md b/docs/c-runtime-library/reference/msize-dbg.md
index b1edd1a907..01ea05ea49 100644
--- a/docs/c-runtime-library/reference/msize-dbg.md
+++ b/docs/c-runtime-library/reference/msize-dbg.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_msize_dbg", "msize_dbg"]
helpviewer_keywords: ["memory blocks", "_msize_dbg function", "msize_dbg function"]
-ms.assetid: a333f4b6-f8a2-4e61-bb69-cb34063b8cef
---
# `_msize_dbg`
@@ -41,13 +40,13 @@ On successful completion, **`_msize_dbg`** returns the size (in bytes) of the sp
For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see [CRT debug heap details](../crt-debug-heap-details.md). For information about the allocation block types and how they're used, see [Types of blocks on the debug heap](../crt-debug-heap-details.md#types-of-blocks-on-the-debug-heap). For information about the differences between standard heap functions and the debug versions, see [Debug versions of heap allocation functions](../debug-versions-of-heap-allocation-functions.md).
-This function validates its parameter. If *`memblock`* is a null pointer, **`_msize_dbg`** invokes an invalid parameter handler, as described in [Parameter validation](../parameter-validation.md). If the error is handled, the function sets `errno` to `EINVAL` and returns -1.
+This function validates its parameter. If *`memblock`* is a null pointer, **`_msize_dbg`** invokes an invalid parameter handler, as described in [Parameter validation](../parameter-validation.md). If the error is handled, the function sets `errno` to `EINVAL` and returns -1 (18,446,744,073,709,551,615 unsigned).
## Requirements
| Routine | Required header |
|---|---|
-| **`_msize_dbg`** | \ |
+| **`_msize_dbg`** | `` |
For more compatibility information, see [Compatibility](../compatibility.md).
diff --git a/docs/c-runtime-library/reference/msize.md b/docs/c-runtime-library/reference/msize.md
index db66cf4361..b5d1cad10b 100644
--- a/docs/c-runtime-library/reference/msize.md
+++ b/docs/c-runtime-library/reference/msize.md
@@ -1,7 +1,7 @@
---
description: "Learn more about: _msize"
title: "_msize"
-ms.date: "4/2/2020"
+ms.date: 07/26/2024
api_name: ["_msize", "_o__msize"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-heap-l1-1-0.dll"]
api_type: ["DLLExport"]
@@ -36,7 +36,7 @@ The **`_msize`** function returns the size, in bytes, of the memory block alloca
When the application is linked with a debug version of the C run-time libraries, **`_msize`** resolves to [`_msize_dbg`](msize-dbg.md). For more information about how the heap is managed during the debugging process, see [The CRT debug heap](../crt-debug-heap-details.md).
-This function validates its parameter. If *`memblock`* is a `NULL` pointer, **`_msize`** invokes an invalid parameter handler, as described in [Parameter validation](../parameter-validation.md). If the error is handled, the function sets `errno` to `EINVAL` and returns -1.
+This function validates its parameter. If *`memblock`* is a `NULL` pointer, **`_msize`** invokes an invalid parameter handler, as described in [Parameter validation](../parameter-validation.md). If the error is handled, the function sets `errno` to `EINVAL` and returns -1 (18,446,744,073,709,551,615 unsigned).
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
diff --git a/docs/c-runtime-library/reference/nextafter-functions.md b/docs/c-runtime-library/reference/nextafter-functions.md
index da24da3c06..f4945d818e 100644
--- a/docs/c-runtime-library/reference/nextafter-functions.md
+++ b/docs/c-runtime-library/reference/nextafter-functions.md
@@ -56,7 +56,7 @@ The **`nextafter`** and **`nexttoward`** function families are equivalent, excep
Because C++ allows overloading, if you include `` you can call overloads of **`nextafter`** and **`nexttoward`** that return **`float`** and **`long double`** types. In a C program, unless you're using the `` macro to call this function, **`nextafter`** and **`nexttoward`** always return **`double`**.
-If you use the `nextafter` or `nexttoward`macro from ``, the type of the argument determines which version of the function is selected. See [Type-generic math](../tgmath.md) for details.
+If you use the `nextafter` or `nexttoward` macro from ``, the type of the argument determines which version of the function is selected. See [Type-generic math](../tgmath.md) for details.
The **`_nextafter`** and **`_nextafterf`** functions are Microsoft-specific. The **`_nextafterf`** function is only available when compiling for x64.
diff --git a/docs/c-runtime-library/reference/not-eq.md b/docs/c-runtime-library/reference/not-eq.md
index e89211cb5c..90877cd219 100644
--- a/docs/c-runtime-library/reference/not-eq.md
+++ b/docs/c-runtime-library/reference/not-eq.md
@@ -1,17 +1,16 @@
---
description: "Learn more about: not_eq"
title: "not_eq"
-ms.date: "11/04/2016"
+ms.date: 08/09/2024
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["ISO646/not_eq", "not_eq", "std::not_eq", "std.not_eq"]
helpviewer_keywords: ["not_eq function"]
-ms.assetid: d87ad299-8b50-4393-a57f-06f70e1f23fb
---
# `not_eq`
-An alternative to the **`!=`** operator.
+An alternative spelling for the **`!=`** operator.
## Syntax
@@ -21,34 +20,40 @@ An alternative to the **`!=`** operator.
## Remarks
-The macro yields the operator **`!=`**.
+C++:
+- **`not_eq`** can be used as alternative to **`!=`**. The [`/permissive-`](../../build/reference/permissive-standards-conformance.md) or [`/Za`](../../build/reference/za-ze-disable-language-extensions.md) compiler option is required.
+- Including `` or `` is deprecated. You can use the alternative spelling without including any header files.
+- There's no alternative spelling for **`==`**.
+
+C:
+- **`not_eq`** is an alternative spelling for **`!=`**. It is provided as a macro in ``, which you must `#include`.
+- There's no alternative spelling for **`==`**.
## Example
```cpp
-// iso646_not_eq.cpp
// compile with: /EHsc
#include
#include
int main( )
{
- using namespace std;
- int a = 0, b = 1;
-
- if (a != b)
- cout << "a is not equal to b" << endl;
-
- if (a not_eq b)
- cout << "a is not equal to b" << endl;
+ int x = 1, y = 2;
+
+ // not_eq is available in C++ and C
+ // This example is for C++, so no header file is needed to use not_eq
+ // When compiling for C, #include to use not_eq
+ if (x not_eq y)
+ {
+ std::cout << "Not equal\n";
+ }
}
```
```Output
-a is not equal to b
-a is not equal to b
+Not equal
```
## Requirements
-**Header:** \
+**Header:** `` is necessary if you are compiling for C.
\ No newline at end of file
diff --git a/docs/c-runtime-library/reference/not.md b/docs/c-runtime-library/reference/not.md
index 54b1235ef3..a878828337 100644
--- a/docs/c-runtime-library/reference/not.md
+++ b/docs/c-runtime-library/reference/not.md
@@ -1,13 +1,12 @@
---
-description: "Learn more about: not"
title: "not"
+description: "Learn more about: not"
ms.date: "11/04/2016"
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["std::not", "std.not", "ISO646/not", "not"]
helpviewer_keywords: ["not function"]
-ms.assetid: d2ddbd5c-33c0-4aff-8961-feac155b4ba1
---
# `not`
@@ -16,7 +15,6 @@ An alternative to the **`!`** operator.
## Syntax
```C
-
#define not !
```
diff --git a/docs/c-runtime-library/reference/open-osfhandle.md b/docs/c-runtime-library/reference/open-osfhandle.md
index cc52f6cf30..6ea534a28c 100644
--- a/docs/c-runtime-library/reference/open-osfhandle.md
+++ b/docs/c-runtime-library/reference/open-osfhandle.md
@@ -44,7 +44,7 @@ These manifest constants are defined in ``:
|--|--|
| `_O_APPEND` | Positions a file pointer to the end of the file before every write operation. |
| `_O_RDONLY` | Opens the file for reading only. |
-| `_O_TEXT` | Opens the file in text (translated) mode. |
+| `_O_TEXT` | Opens the file in ANSI text (translated) mode. |
| `_O_WTEXT` | Opens the file in Unicode (translated UTF-16) mode. |
The **`_open_osfhandle`** call transfers ownership of the Win32 file handle to the file descriptor. To close a file opened by using **`_open_osfhandle`**, call [`_close`](close.md). The underlying OS file handle is also closed by a call to **`_close`**. Don't call the Win32 function `CloseHandle` on the original handle. If the file descriptor is owned by a `FILE *` stream, then a call to [`fclose`](fclose-fcloseall.md) closes both the file descriptor and the underlying handle. In this case, don't call **`_close`** on the file descriptor or `CloseHandle` on the original handle.
diff --git a/docs/c-runtime-library/reference/open-wopen.md b/docs/c-runtime-library/reference/open-wopen.md
index 487b3a3f0b..6b72d3b25f 100644
--- a/docs/c-runtime-library/reference/open-wopen.md
+++ b/docs/c-runtime-library/reference/open-wopen.md
@@ -79,7 +79,7 @@ The **`_open`** function opens the file specified by *`filename`* and prepares i
| `_O_RDONLY` | Opens a file for reading only. Can't be specified with `_O_RDWR` or `_O_WRONLY`. |
| `_O_RDWR` | Opens a file for both reading and writing. Can't be specified with `_O_RDONLY` or `_O_WRONLY`. |
| `_O_SEQUENTIAL` | Specifies that caching is optimized for, but not restricted to, sequential access from disk. |
-| `_O_TEXT` | Opens a file in text (translated) mode. (For more information, see [Text and binary mode file I/O](../text-and-binary-mode-file-i-o.md) and [`fopen`](fopen-wfopen.md).) |
+| `_O_TEXT` | Opens a file in ANSI text (translated) mode. (For more information, see [Text and binary mode file I/O](../text-and-binary-mode-file-i-o.md) and [`fopen`](fopen-wfopen.md).) |
| `_O_TRUNC` | Opens a file and truncates it to zero length; the file must have write permission. Can't be specified with `_O_RDONLY`. `_O_TRUNC` used with `_O_CREAT` opens an existing file or creates a file. **Note:** The `_O_TRUNC` flag destroys the contents of the specified file. |
| `_O_WRONLY` | Opens a file for writing only. Can't be specified with `_O_RDONLY` or `_O_RDWR`. |
| `_O_U16TEXT` | Opens a file in Unicode UTF-16 mode. |
diff --git a/docs/c-runtime-library/reference/or-eq.md b/docs/c-runtime-library/reference/or-eq.md
index f9861186e4..86d34f9fb7 100644
--- a/docs/c-runtime-library/reference/or-eq.md
+++ b/docs/c-runtime-library/reference/or-eq.md
@@ -1,13 +1,12 @@
---
-description: "Learn more about: or_eq"
title: "or_eq"
+description: "Learn more about: or_eq"
ms.date: "11/04/2016"
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["std::or_eq", "ISO646/or_eq", "or_eq", "std.or_eq"]
helpviewer_keywords: ["or_eq function"]
-ms.assetid: 1eb92464-ed58-40d8-a30e-f0a6aa2f4318
---
# `or_eq`
@@ -16,7 +15,6 @@ An alternative to the `|=` operator.
## Syntax
```C
-
#define or_eq |=
```
diff --git a/docs/c-runtime-library/reference/pipe.md b/docs/c-runtime-library/reference/pipe.md
index de49769314..084b7d4666 100644
--- a/docs/c-runtime-library/reference/pipe.md
+++ b/docs/c-runtime-library/reference/pipe.md
@@ -59,7 +59,7 @@ The standard output descriptor of `PROGRAM1` is attached to the pipe's write des
The **`_pipe`** function returns two file descriptors to the pipe in the *`pfds`* argument. The element *`pfds`*[0] contains the read descriptor, and the element *`pfds`*[1] contains the write descriptor. Pipe file descriptors are used in the same way as other file descriptors. (The low-level input and output functions **`_read`** and **`_write`** can read from and write to a pipe.) To detect the end-of-pipe condition, check for a **`_read`** request that returns 0 as the number of bytes read.
-The *`psize`* argument specifies the amount of memory, in bytes, to reserve for the pipe. The *`textmode`* argument specifies the translation mode for the pipe. The manifest constant `_O_TEXT` specifies a text translation, and the constant `_O_BINARY` specifies binary translation. (See [`fopen`, `_wfopen`](fopen-wfopen.md) for a description of text and binary modes.) If the *`textmode`* argument is 0, **`_pipe`** uses the default translation mode that's specified by the default-mode variable [`_fmode`](../fmode.md).
+The *`psize`* argument specifies the amount of memory, in bytes, to reserve for the pipe. The *`textmode`* argument specifies the translation mode for the pipe. The manifest constant `_O_TEXT` specifies an ANSI text translation, and the constant `_O_BINARY` specifies binary translation. (See [`fopen`, `_wfopen`](fopen-wfopen.md) for a description of text and binary modes.) If the *`textmode`* argument is 0, **`_pipe`** uses the default translation mode that's specified by the default-mode variable [`_fmode`](../fmode.md).
In multithreaded programs, no locking is performed. The file descriptors that are returned are newly opened and shouldn't be referenced by any thread until after the **`_pipe`** call is complete.
@@ -105,7 +105,6 @@ enum PIPES { READ, WRITE }; /* Constants 0 and 1 for READ and WRITE */
int main( int argc, char *argv[] )
{
-
int fdpipe[2];
char hstr[20];
int pid, problem, c;
diff --git a/docs/c-runtime-library/reference/putc-nolock-putwc-nolock.md b/docs/c-runtime-library/reference/putc-nolock-putwc-nolock.md
index 2cac422792..6c629ae81f 100644
--- a/docs/c-runtime-library/reference/putc-nolock-putwc-nolock.md
+++ b/docs/c-runtime-library/reference/putc-nolock-putwc-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _putc_nolock, _putwc_nolock"
title: "_putc_nolock, _putwc_nolock"
+description: "Learn more about: _putc_nolock, _putwc_nolock"
ms.date: "4/2/2020"
api_name: ["_putc_nolock", "_putwc_nolock", "_o__putc_nolock", "_o__putwc_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_puttc_nolock", "puttc_nolock", "putwc_nolock", "_putwc_nolock", "_putc_nolock", "putc_nolock"]
helpviewer_keywords: ["puttc_nolock function", "putc_nolock function", "_putc_nolock function", "streams, writing characters to", "characters, writing", "putwc_nolock function", "_puttc_nolock function", "_putwc_nolock function"]
-ms.assetid: 3cfc7f21-c9e8-4b7f-b0fb-af0d4d85e7e1
---
# `_putc_nolock`, `_putwc_nolock`
-Writes a character to a stream without locking the thread.
+Writes a character to a stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/putch-nolock-putwch-nolock.md b/docs/c-runtime-library/reference/putch-nolock-putwch-nolock.md
index b3e11e0e26..d97eb45b18 100644
--- a/docs/c-runtime-library/reference/putch-nolock-putwch-nolock.md
+++ b/docs/c-runtime-library/reference/putch-nolock-putwch-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _putch_nolock, _putwch_nolock"
title: "_putch_nolock, _putwch_nolock"
+description: "Learn more about: _putch_nolock, _putwch_nolock"
ms.date: "4/2/2020"
api_name: ["_putwch_nolock", "_putch_nolock", "_o__putch_nolock", "_o__putwch_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-conio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_putch_nolock", "_puttch_nolock", "putch_nolock", "putwch_nolock", "_putwch_nolock"]
helpviewer_keywords: ["putwch_nolock function", "puttch_nolock function", "characters, writing", "putch_nolock function", "_putch_nolock function", "_puttch_nolock function", "console, writing characters to", "_putwch_nolock function"]
-ms.assetid: edbc811d-bac6-47fa-a872-fe4f3a1590b0
---
# `_putch_nolock`, `_putwch_nolock`
-Writes a character to the console without locking the thread.
+Writes a character to the console without locking.
> [!IMPORTANT]
> This API cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported in Universal Windows Platform apps](../../cppcx/crt-functions-not-supported-in-universal-windows-platform-apps.md).
diff --git a/docs/c-runtime-library/reference/putchar-nolock-putwchar-nolock.md b/docs/c-runtime-library/reference/putchar-nolock-putwchar-nolock.md
index 4748670c50..6fe752c348 100644
--- a/docs/c-runtime-library/reference/putchar-nolock-putwchar-nolock.md
+++ b/docs/c-runtime-library/reference/putchar-nolock-putwchar-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _putchar_nolock, _putwchar_nolock"
title: "_putchar_nolock, _putwchar_nolock"
+description: "Learn more about: _putchar_nolock, _putwchar_nolock"
ms.date: "11/04/2016"
api_name: ["_putchar_nolock", "_putwchar_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["putwchar_nolock", "_puttchar_nolock", "_putchar_nolock", "_putwchar_nolock", "putchar_nolock"]
helpviewer_keywords: ["_puttchar_nolock function", "putchar_nolock function", "characters, writing", "standard output, writing to", "putwchar_nolock function", "_putchar_nolock function", "_putwchar_nolock function", "puttchar_nolock function"]
-ms.assetid: 9ac68092-bfc3-4352-b486-c3e780220575
---
# `_putchar_nolock`, `_putwchar_nolock`
-Writes a character to `stdout` without locking the thread.
+Writes a character to `stdout` without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/putenv-s-wputenv-s.md b/docs/c-runtime-library/reference/putenv-s-wputenv-s.md
index 31b8fd94bb..6437099f5c 100644
--- a/docs/c-runtime-library/reference/putenv-s-wputenv-s.md
+++ b/docs/c-runtime-library/reference/putenv-s-wputenv-s.md
@@ -1,21 +1,23 @@
---
description: "Learn more about: _putenv_s, _wputenv_s"
-title: "_putenv_s, _wputenv_s"
+title: "_putenv_s, _wputenv_s, _tputenv_s"
ms.date: "4/2/2020"
-api_name: ["_wputenv_s", "_putenv_s", "_o__putenv_s", "_o__wputenv_s"]
+api_name: ["_wputenv_s", "_putenv_s", "_tputenv_s", "_o__putenv_s", "_o__wputenv_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-environment-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["putenv_s", "wputenv_s", "_wputenv_s", "_putenv_s"]
-helpviewer_keywords: ["wputenv_s function", "_putenv_s function", "environment variables, deleting", "putenv_s function", "_wputenv_s function", "environment variables, creating", "environment variables, modifying"]
+f1_keywords: ["putenv_s", "wputenv_s", "_wputenv_s", "_putenv_s", "_tputenv_s"]
+helpviewer_keywords: ["wputenv_s function", "_putenv_s function", "environment variables, deleting", "putenv_s function", "_wputenv_s function", "environment variables, creating", "environment variables, modifying", "_tputenv_s function"]
---
-# `_putenv_s`, `_wputenv_s`
+# `_putenv_s`, `_wputenv_s`, `_tputenv_s`
Creates, modifies, or removes environment variables. These functions are versions of [`_putenv`, `_wputenv`](putenv-wputenv.md) that have security enhancements, as described in [Security features in the CRT](../security-features-in-the-crt.md).
> [!IMPORTANT]
> This API cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported in Universal Windows Platform apps](../../cppcx/crt-functions-not-supported-in-universal-windows-platform-apps.md).
+For `_tputenv_s`, see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -56,11 +58,13 @@ The **`_putenv_s`** function adds new environment variables or modifies the valu
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` function | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
-| `_tputenv_s` | **`_putenv_s`** | **`_putenv_s`** | **`_wputenv_s`** |
+| `_tputenv_s` | `_putenv_s` | `_putenv_s` | `_wputenv_s` |
*`varname`* is the name of the environment variable to be added or modified and *`value_string`* is the variable's value. If *`varname`* is already part of the environment, its value is replaced by *`value_string`*; otherwise, the new *`varname`* variable and its *`value_string`* are added to the environment. You can remove a variable from the environment by specifying an empty string (that is, `""`) for *`value_string`*.
diff --git a/docs/c-runtime-library/reference/qsort.md b/docs/c-runtime-library/reference/qsort.md
index b465c704a9..9364fefb82 100644
--- a/docs/c-runtime-library/reference/qsort.md
+++ b/docs/c-runtime-library/reference/qsort.md
@@ -1,7 +1,7 @@
---
title: "qsort"
description: "Describes the Microsoft C runtime quick sort API `qsort`"
-ms.date: "10/23/2020"
+ms.date: "8/2/2023"
api_name: ["qsort", "_o_qsort"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ntdll.dll", "ucrtbase.dll", "api-ms-win-crt-utility-l1-1-0.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
@@ -45,7 +45,7 @@ The **`qsort`** function implements a quick-sort algorithm to sort an array of *
**`qsort`** calls the *`compare`* routine one or more times during the sort, and passes pointers to two array elements on each call. If *`compare`* indicates two elements are the same, their order in the resulting sorted array is unspecified.
```C
-compare( (void *) & elem1, (void *) & elem2 );
+compare(const void *elem1, const void *elem2);
```
The routine compares the elements and returns one of the following values.
diff --git a/docs/c-runtime-library/reference/raise.md b/docs/c-runtime-library/reference/raise.md
index 2b33716eae..e3fe3e05b6 100644
--- a/docs/c-runtime-library/reference/raise.md
+++ b/docs/c-runtime-library/reference/raise.md
@@ -14,7 +14,7 @@ helpviewer_keywords: ["signals, sending to executing programs", "raise function"
Sends a signal to the executing program.
> [!NOTE]
-> Do not use this method to shut down a Microsoft Store app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/legal/windows/agreements/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
+> Do not use this method to shut down a Microsoft Store app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/windows/apps/publish/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
## Syntax
diff --git a/docs/c-runtime-library/reference/read.md b/docs/c-runtime-library/reference/read.md
index ad0fc6fd92..2e7096eca6 100644
--- a/docs/c-runtime-library/reference/read.md
+++ b/docs/c-runtime-library/reference/read.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _read"
title: "_read"
+description: "Learn more about: _read"
ms.date: "4/2/2020"
api_name: ["_read", "_o__read"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -123,4 +123,4 @@ Read 19 bytes from file
[`_creat`, `_wcreat`](creat-wcreat.md)\
[`fread`](fread.md)\
[`_open`, `_wopen`](open-wopen.md)\
-[`_write`](write.md)\
+[`_write`](write.md)
diff --git a/docs/c-runtime-library/reference/recalloc.md b/docs/c-runtime-library/reference/recalloc.md
index 2e10f1ee09..09cd09dea3 100644
--- a/docs/c-runtime-library/reference/recalloc.md
+++ b/docs/c-runtime-library/reference/recalloc.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _recalloc"
title: "_recalloc"
+description: "Learn more about: _recalloc"
ms.date: "4/2/2020"
api_name: ["_recalloc", "_o__recalloc"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-heap-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_recalloc", "recalloc"]
helpviewer_keywords: ["_recalloc function", "recalloc function"]
-ms.assetid: 1db8305a-3f03-418c-8844-bf9149f63046
---
# `_recalloc`
@@ -18,7 +17,7 @@ A combination of `realloc` and `calloc`. Reallocates an array in memory and init
```C
void *_recalloc(
- void *memblock
+ void *memblock,
size_t num,
size_t size
);
diff --git a/docs/c-runtime-library/reference/remquo-remquof-remquol.md b/docs/c-runtime-library/reference/remquo-remquof-remquol.md
index 9aa9613702..f6236f9679 100644
--- a/docs/c-runtime-library/reference/remquo-remquof-remquol.md
+++ b/docs/c-runtime-library/reference/remquo-remquof-remquol.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["remquof", "remquol", "remquo"]
helpviewer_keywords: ["remquol function", "remquof function", "remquo function"]
-ms.assetid: a1d3cb8b-8027-4cd3-8deb-04eb17f299fc
---
# `remquo`, `remquof`, `remquol`
@@ -43,7 +42,7 @@ A pointer to an integer to store a value that has the sign and approximate magni
## Remarks
-The **`remquo`** function calculates the floating-point remainder `f` of *`x`* / *`y`* such that *`x`* = `n` \* *`y`* + `f`*, where `n` is an integer, `f` has the same sign as *`x`*, and the absolute value of `f` is less than the absolute value of *`y`*.
+The **`remquo`** function calculates the floating-point remainder `f` of *`x`* / *`y`* such that *`x`* = `n` \* *`y`* + *`f`*, where `n` is an integer, `f` has the same sign as *`x`*, and the absolute value of `f` is less than the absolute value of *`y`*.
C++ allows overloading, so you can call overloads of **`remquo`** that take and return **`float`** or **`long double`** values. In a C program, unless you're using the \ macro to call this function, **`remquo`** always takes two **`double`** arguments and returns a **`double`**.
diff --git a/docs/c-runtime-library/reference/rmtmp.md b/docs/c-runtime-library/reference/rmtmp.md
index 857dc4c035..7fac6abd1a 100644
--- a/docs/c-runtime-library/reference/rmtmp.md
+++ b/docs/c-runtime-library/reference/rmtmp.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _rmtmp"
title: "_rmtmp"
+description: "Learn more about: _rmtmp"
ms.date: "4/2/2020"
api_name: ["_rmtmp", "_o__rmtmp"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_rmtmp"]
helpviewer_keywords: ["removing temporary files", "_rmtmp function", "files [C++], temporary", "rmtmp function", "files [C++], removing", "temporary files [C++], removing"]
-ms.assetid: 7419501e-2587-4f2a-b469-0dca07f84736
---
# `_rmtmp`
@@ -17,7 +16,6 @@ Removes temporary files.
## Syntax
```C
-
int _rmtmp( void );
```
diff --git a/docs/c-runtime-library/reference/rotl-rotl64-rotr-rotr64.md b/docs/c-runtime-library/reference/rotl-rotl64-rotr-rotr64.md
index dfdbaae96f..c095e8cada 100644
--- a/docs/c-runtime-library/reference/rotl-rotl64-rotr-rotr64.md
+++ b/docs/c-runtime-library/reference/rotl-rotl64-rotr-rotr64.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_rotr64", "rotl64", "_rotl64", "rotr64", "rotr", "_rotr", "_rotl", "rotl"]
helpviewer_keywords: ["rotl64 function", "_rotl function", "rotr function", "rotr64 function", "_rotr function", "rotl function", "_rotl64 function", "rotating bits", "_rotr64 function", "bits, rotating"]
-ms.assetid: cfce439b-366f-4584-8ab1-d527b13fcfc6
---
# `_rotl`, `_rotl64`, `_rotr`, `_rotr64`
@@ -17,7 +16,6 @@ Rotates bits to the left (**`_rotl`**) or right (**`_rotr`**).
## Syntax
```C
-
unsigned int _rotl(
unsigned int value,
int shift
diff --git a/docs/c-runtime-library/reference/rtc-numerrors.md b/docs/c-runtime-library/reference/rtc-numerrors.md
index d512c8f402..f2428d8e7a 100644
--- a/docs/c-runtime-library/reference/rtc-numerrors.md
+++ b/docs/c-runtime-library/reference/rtc-numerrors.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _RTC_NumErrors"
title: "_RTC_NumErrors"
+description: "Learn more about: _RTC_NumErrors"
ms.date: "11/04/2016"
api_name: ["_RTC_NumErrors"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_RTC_NumErrors", "RTC_NumErrors"]
helpviewer_keywords: ["run-time errors", "_RTC_NumErrors function", "RTC_NumErrors function"]
-ms.assetid: 7e82adae-38e2-4f8b-bc0b-37bda8109fd1
---
# `_RTC_NumErrors`
@@ -17,7 +16,6 @@ Returns the total number of errors that can be detected by run-time error checks
## Syntax
```C
-
int _RTC_NumErrors( void );
```
diff --git a/docs/c-runtime-library/reference/set-abort-behavior.md b/docs/c-runtime-library/reference/set-abort-behavior.md
index 1abfb48f28..957edb7430 100644
--- a/docs/c-runtime-library/reference/set-abort-behavior.md
+++ b/docs/c-runtime-library/reference/set-abort-behavior.md
@@ -14,7 +14,7 @@ helpviewer_keywords: ["aborting programs", "_set_abort_behavior function", "set_
Specifies the action to be taken when a program is abnormally terminated.
> [!NOTE]
-> Do not use the [`abort`](abort.md) function to shut down a Microsoft Store app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/legal/windows/agreements/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
+> Do not use the [`abort`](abort.md) function to shut down a Microsoft Store app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/windows/apps/publish/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
## Syntax
diff --git a/docs/c-runtime-library/reference/set-se-translator.md b/docs/c-runtime-library/reference/set-se-translator.md
index d695b3975d..a52026c5df 100644
--- a/docs/c-runtime-library/reference/set-se-translator.md
+++ b/docs/c-runtime-library/reference/set-se-translator.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _set_se_translator"
title: "_set_se_translator"
+description: "Learn more about: _set_se_translator"
ms.date: "1/14/2021"
api_name: ["_set_se_translator"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -212,4 +212,4 @@ Caught SE_Exception, error c0000094
[`set_terminate`](set-terminate-crt.md)\
[`set_unexpected`](set-unexpected-crt.md)\
[`terminate`](terminate-crt.md)\
-[`unexpected`](unexpected-crt.md)\
+[`unexpected`](unexpected-crt.md)
diff --git a/docs/c-runtime-library/reference/set-unexpected-crt.md b/docs/c-runtime-library/reference/set-unexpected-crt.md
index c6bc98683d..8b5ee60a84 100644
--- a/docs/c-runtime-library/reference/set-unexpected-crt.md
+++ b/docs/c-runtime-library/reference/set-unexpected-crt.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: set_unexpected (CRT)"
title: "set_unexpected (CRT)"
+description: "Learn more about: set_unexpected (CRT)"
ms.date: "1/14/2021"
api_name: ["set_unexpected"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["set_unexpected"]
helpviewer_keywords: ["set_unexpected function", "unexpected function", "exception handling, termination"]
-ms.assetid: ebcef032-4771-48e5-88aa-2a1ab8750aa6
---
# `set_unexpected` (CRT)
@@ -62,4 +61,4 @@ For more compatibility information, see [Compatibility](../compatibility.md).
[`_get_unexpected`](get-unexpected.md)\
[`set_terminate`](set-terminate-crt.md)\
[`terminate`](terminate-crt.md)\
-[`unexpected`](unexpected-crt.md)\
+[`unexpected`](unexpected-crt.md)
diff --git a/docs/c-runtime-library/reference/setlocale-wsetlocale.md b/docs/c-runtime-library/reference/setlocale-wsetlocale.md
index 8eefaa426f..99991d91a3 100644
--- a/docs/c-runtime-library/reference/setlocale-wsetlocale.md
+++ b/docs/c-runtime-library/reference/setlocale-wsetlocale.md
@@ -1,7 +1,7 @@
---
title: "setlocale, _wsetlocale"
description: "Describes the Microsoft C runtime (CRT) library functions setlocale and _wsetlocale."
-ms.date: 05/05/2022
+ms.date: 01/04/2024
api_name: ["_wsetlocale", "setlocale", "_o__wsetlocale", "_o_setlocale"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-locale-l1-1-0.dll"]
api_type: ["DLLExport"]
@@ -12,7 +12,7 @@ no-loc: [setlocale, _wsetlocale]
---
# `setlocale`, `_wsetlocale`
-Sets or retrieves the run-time locale.
+Set or retrieve the run-time locale.
## Syntax
@@ -21,6 +21,7 @@ char *setlocale(
int category,
const char *locale
);
+
wchar_t *_wsetlocale(
int category,
const wchar_t *locale
@@ -40,9 +41,17 @@ Locale specifier.
If a valid *`locale`* and *`category`* are given, the functions return a pointer to the string associated with the specified *`locale`* and *`category`*.
If the *`locale`* argument is `NULL`, the functions return the current locale.
-If the *`locale`* or *`category`* isn't valid, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, each function sets `errno` to `EINVAL`, and returns `NULL`.
+If an invalid argument is passed to either function, the return value is `NULL`.
+The behavior for invalid arguments is as follows:
+
+|Function | Invalid parameter | Invalid handler invoked as described in [Parameter validation](../parameter-validation.md)| Sets `errno` |
+|---------|---------|---------|
+| `setlocale` | *`category`* | yes | yes |
+| `setlocale` | *`locale`* | no | no |
+| `_wsetlocale` | *`category`* | yes | yes |
+| `_wsetlocale` | *`locale`* | no | no |
-The call
+The call:
```C
setlocale( LC_ALL, "en-US" );
@@ -78,7 +87,7 @@ The *`category`* argument specifies the parts of a program's locale information
| `LC_COLLATE` | The `strcoll`, `_stricoll`, `wcscoll`, `_wcsicoll`, `strxfrm`, `_strncoll`, `_strnicoll`, `_wcsncoll`, `_wcsnicoll`, and `wcsxfrm` functions. |
| `LC_CTYPE` | The character-handling functions (except `isdigit`, `isxdigit`, `mbstowcs`, and `mbtowc`, which are unaffected). |
| `LC_MONETARY` | Monetary-formatting information returned by the `localeconv` function. |
-| `LC_NUMERIC` | Decimal-point character for the formatted output routines (such as `printf`), for the data-conversion routines, and for the non-monetary formatting information returned by `localeconv`. In addition to the decimal-point character, `LC_NUMERIC` sets the thousands separator and the grouping control string returned by [`localeconv`](localeconv.md). |
+| `LC_NUMERIC` | Decimal-point character for the formatted output routines (such as `printf`), for the data-conversion routines, and for the nonmonetary formatting information returned by `localeconv`. In addition to the decimal-point character, `LC_NUMERIC` sets the thousands separator and the grouping control string returned by [`localeconv`](localeconv.md). |
| `LC_TIME` | The `strftime` and `wcsftime` functions. |
This function validates the category parameter. If the category parameter isn't one of the values given in the previous table, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, the function sets `errno` to `EINVAL` and returns `NULL`.
@@ -173,7 +182,7 @@ The function [`_configthreadlocale`](configthreadlocale.md) is used to control w
## UTF-8 support
-Starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code page. The change means that `char` strings passed to C runtime functions can expect strings in the UTF-8 encoding. To enable UTF-8 mode, use `".UTF8"` as the code page when using **`setlocale`**. For example, `setlocale(LC_ALL, ".UTF8")` will use the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.
+Starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code page. The change means that `char` strings passed to C runtime functions can expect strings in the UTF-8 encoding. To enable UTF-8 mode, use `".UTF8"` as the code page when using **`setlocale`**. For example, `setlocale(LC_ALL, ".UTF8")` uses the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.
The string to specify UTF-8 mode is:
@@ -192,7 +201,7 @@ The following examples show how to specify the UTF-8 string:
After calling `setlocale(LC_ALL, ".UTF8")`, you may pass "😊" to `mbtowcs` and it will be properly translated to a `wchar_t` string. Previously, there wasn't a locale setting available to do this translation.
-UTF-8 mode is also enabled for functions that have historically translated `char` strings using the default Windows ANSI code page (ACP). For example, calling [`_mkdir("😊")`](../reference/mkdir-wmkdir.md) while using a UTF-8 code page will correctly produce a directory with that emoji as the folder name, instead of requiring the ACP to be changed to UTF-8 before running your program. Likewise, calling [`_getcwd()`](../reference/getcwd-wgetcwd.md) in that folder will return a UTF-8 encoded string. For compatibility, the ACP is still used if the C locale code page isn't set to UTF-8.
+UTF-8 mode is also enabled for functions that have historically translated `char` strings using the default Windows ANSI code page (ACP). For example, calling [`_mkdir("😊")`](../reference/mkdir-wmkdir.md) while using a UTF-8 code page will correctly produce a directory with that emoji as the folder name, instead of requiring the ACP to be changed to UTF-8 before running your program. Likewise, calling [`_getcwd()`](../reference/getcwd-wgetcwd.md) in that folder returns a UTF-8 encoded string. For compatibility, the ACP is still used if the C locale code page isn't set to UTF-8.
The following aspects of the C Runtime can't use UTF-8 because they're set during program startup and must use the default Windows ANSI code page (ACP): [`__argv`](../argc-argv-wargv.md), [`_acmdln`](../acmdln-tcmdln-wcmdln.md), and [`_pgmptr`](../pgmptr-wpgmptr.md).
@@ -249,9 +258,8 @@ int get_date(unsigned char* str)
return 0;
}
-// This thread sets its locale to the argument
-// and prints the date.
-uintptr_t __stdcall SecondThreadFunc( void* pArguments )
+// This thread sets its locale to the argument and prints the date.
+unsigned __stdcall SecondThreadFunc(void* pArguments)
{
unsigned char str[BUFF_SIZE];
char * locale = (char *)pArguments;
@@ -289,7 +297,7 @@ int main()
// Create the second thread with a German locale.
// Our thread function takes an argument of the locale to use.
hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc,
- "de-DE", 0, &threadID );
+ (void*)"de-DE", 0, &threadID );
if (get_date(str) == 0)
{
@@ -307,10 +315,10 @@ int main()
```Output
The thread locale is now set to en-US.
-The time in en-US locale is: 'Wednesday, May 12, 2004'
+The date in en-US locale is: 'Thursday, January 4, 2024'
The thread locale is now set to de-DE.
-The time in de-DE locale is: 'Mittwoch, 12. Mai 2004'
+The date in de-DE locale is: 'Donnerstag, 4. Januar 2024'
```
## See also
diff --git a/docs/c-runtime-library/reference/setmode.md b/docs/c-runtime-library/reference/setmode.md
index 6cf30c8844..009bc3bdff 100644
--- a/docs/c-runtime-library/reference/setmode.md
+++ b/docs/c-runtime-library/reference/setmode.md
@@ -41,7 +41,7 @@ For more information about these and other return codes, see [`errno`, `_doserrn
## Remarks
-The **`_setmode`** function sets to *`mode`* the translation mode of the file given by *`fd`*. Passing `_O_TEXT` as *`mode`* sets text (that is, translated) mode. Carriage return-line feed (CR-LF) combinations are translated into a single line feed character on input. Line feed characters are translated into CR-LF combinations on output. Passing `_O_BINARY` sets binary (untranslated) mode, in which these translations are suppressed.
+The **`_setmode`** function sets to *`mode`* the translation mode of the file given by *`fd`*. Passing `_O_TEXT` as *`mode`* sets ANSI text (that is, translated) mode. Carriage return-line feed (CR-LF) combinations are translated into a single line feed character on input. Line feed characters are translated into CR-LF combinations on output. Passing `_O_BINARY` sets binary (untranslated) mode, in which these translations are suppressed.
You can also pass `_O_U16TEXT`, `_O_U8TEXT`, or `_O_WTEXT` to enable Unicode mode, as demonstrated in the second example later in this document.
diff --git a/docs/c-runtime-library/reference/signal.md b/docs/c-runtime-library/reference/signal.md
index a9c623188f..ad4bd650a1 100644
--- a/docs/c-runtime-library/reference/signal.md
+++ b/docs/c-runtime-library/reference/signal.md
@@ -14,7 +14,7 @@ helpviewer_keywords: ["signal function"]
Sets interrupt signal handling.
> [!IMPORTANT]
-> Do not use this method to shut down a Microsoft Store app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/legal/windows/agreements/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
+> Do not use this method to shut down a Microsoft Store app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the [Microsoft Store policies](/windows/apps/publish/store-policies). For more information, see [UWP app lifecycle](/windows/uwp/launch-resume/app-lifecycle).
## Syntax
diff --git a/docs/c-runtime-library/reference/sin-sinf-sinl.md b/docs/c-runtime-library/reference/sin-sinf-sinl.md
index 82e1d8745b..841be1e4a4 100644
--- a/docs/c-runtime-library/reference/sin-sinf-sinl.md
+++ b/docs/c-runtime-library/reference/sin-sinf-sinl.md
@@ -96,4 +96,4 @@ cos( 1.570796 ) = 0.000000
[`atan`, `atanf`, `atanl`, `atan2`, `atan2f`, `atan2l`](atan-atanf-atanl-atan2-atan2f-atan2l.md)\
[`cos`, `cosf`, `cosl`](cos-cosf-cosl.md)\
[`tan`, `tanf`, `tanl`](tan-tanf-tanl.md)\
-[`_CIsin`](../cisin.md)\
+[`_CIsin`](../cisin.md)
diff --git a/docs/c-runtime-library/reference/snprintf-s-snprintf-s-l-snwprintf-s-snwprintf-s-l.md b/docs/c-runtime-library/reference/snprintf-s-snprintf-s-l-snwprintf-s-snwprintf-s-l.md
index a187f9cac4..548a9fccf6 100644
--- a/docs/c-runtime-library/reference/snprintf-s-snprintf-s-l-snwprintf-s-snwprintf-s-l.md
+++ b/docs/c-runtime-library/reference/snprintf-s-snprintf-s-l-snwprintf-s-snwprintf-s-l.md
@@ -1,7 +1,7 @@
---
description: "Learn more about: _snprintf_s, _snprintf_s_l, _snwprintf_s, _snwprintf_s_l"
title: "_snprintf_s, _snprintf_s_l, _snwprintf_s, _snwprintf_s_l"
-ms.date: "3/9/2021"
+ms.date: 06/27/2023
api_name: ["_snprintf_s", "_snprintf_s_l", "_snwprintf_s", "_snwprintf_s_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
@@ -11,7 +11,7 @@ helpviewer_keywords: ["_snprintf_s_l function", "_snwprintf_s_l function", "_snt
---
# `_snprintf_s`, `_snprintf_s_l`, `_snwprintf_s`, `_snwprintf_s_l`
-Writes formatted data to a string. These functions are versions of [`snprintf`, `_snprintf`, `_snprintf_l`, `_snwprintf`, `_snwprintf_l`](snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md) with security enhancements as described in [Security features in the CRT](../security-features-in-the-crt.md).
+Writes formatted data to a string. These functions are versions of [`snprintf`, `_snprintf`, `_snprintf_l`, `_snwprintf`, `_snwprintf_l`](snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md) with security enhancements described in [Security features in the CRT](../security-features-in-the-crt.md).
## Syntax
@@ -23,6 +23,7 @@ int _snprintf_s(
const char *format [,
argument] ...
);
+
int _snprintf_s_l(
char *buffer,
size_t sizeOfBuffer,
@@ -31,6 +32,7 @@ int _snprintf_s_l(
_locale_t locale [,
argument] ...
);
+
int _snwprintf_s(
wchar_t *buffer,
size_t sizeOfBuffer,
@@ -38,6 +40,7 @@ int _snwprintf_s(
const wchar_t *format [,
argument] ...
);
+
int _snwprintf_s_l(
wchar_t *buffer,
size_t sizeOfBuffer,
@@ -46,6 +49,7 @@ int _snwprintf_s_l(
_locale_t locale [,
argument] ...
);
+
template
int _snprintf_s(
char (&buffer)[size],
@@ -53,6 +57,7 @@ int _snprintf_s(
const char *format [,
argument] ...
); // C++ only
+
template
int _snwprintf_s(
wchar_t (&buffer)[size],
@@ -68,10 +73,10 @@ int _snwprintf_s(
Storage location for the output.
*`sizeOfBuffer`*\
-The size of the storage location for output. Size in **`bytes`** for **`_snprintf_s`** or size in **`words`** for **`_snwprintf_s`**.
+The size of the storage location for output. Size in **bytes** for the functions that take `char`, and **words** for those that take `wchar_t`.
*`count`*\
-Maximum number of characters to store, or [`_TRUNCATE`](../truncate.md).
+Maximum number of characters to write. For the functions that take `wchar_t`, it's the maximum number of wide characters to write. Or [`_TRUNCATE`](../truncate.md).
*`format`*\
Format-control string.
@@ -84,27 +89,46 @@ The locale to use.
## Return value
-**`_snprintf_s`** returns the number of characters stored in *`buffer`*, not counting the terminating null character. **`_snwprintf_s`** returns the number of wide characters stored in *`buffer`*, not counting the terminating null wide character.
+The number of characters written, not including the terminating `NULL`. A negative value is returned if an output error occurs. See [Behavior summary](#behavior-summary) for details.
-If the storage required to store the data and a terminating null exceeds *`sizeOfBuffer`*, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution continues after the invalid parameter handler, these functions set *`buffer`* to an empty string, set `errno` to `ERANGE`, and return -1.
+## Remarks
-If *`buffer`* or *`format`* is a `NULL` pointer, or if *`count`* is less than or equal to zero, the invalid parameter handler is invoked. If execution is allowed to continue, these functions set `errno` to `EINVAL` and return -1.
+The **`_snprintf_s`** function formats and stores *`count`* or fewer characters in *`buffer`* and appends a terminating `NULL`. Each argument (if any) is converted and output according to the corresponding format specification in *`format`*. The formatting is consistent with the **`printf`** family of functions; see [Format specification syntax: `printf` and `wprintf` functions](../format-specification-syntax-printf-and-wprintf-functions.md). If copying occurs between strings that overlap, the behavior is undefined.
-For information about these and other error codes, see [`errno`, `_doserrno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
+### Behavior summary
-## Remarks
+For the following table:
-The **`_snprintf_s`** function formats and stores *`count`* or fewer characters in *`buffer`* and appends a terminating null. Each argument (if any) is converted and output according to the corresponding format specification in *`format`*. The formatting is consistent with the **`printf`** family of functions; see [Format specification syntax: `printf` and `wprintf` functions](../format-specification-syntax-printf-and-wprintf-functions.md). If copying occurs between strings that overlap, the behavior is undefined.
+-Let `len` be the size of the formatted data. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+- Characters refer to `char` characters for functions that take a `char` buffer, and to `wchar_t` characters for functions that take a `wchar_t` buffer.
+- For more information about the invalid parameter handler, see [Parameter Validation](../../c-runtime-library/parameter-validation.md).
-If *`count`* is [`_TRUNCATE`](../truncate.md), then **`_snprintf_s`** writes as much of the string as will fit in *`buffer`* while leaving room for a terminating null. If the entire string (with terminating null) fits in *`buffer`*, then **`_snprintf_s`** returns the number of characters written (not including the terminating null); otherwise, **`_snprintf_s`** returns -1 to indicate that truncation occurred.
+| Condition | Behavior | Return value | `errno` | Invokes invalid parameter handler |
+|--|--|--|--|--|
+| Success | Writes the characters into the buffer using the specified format string.| The number of characters written, not including the terminating `NULL`. | N/A | No |
+| Encoding error during formatting | If processing string specifier `s`, `S`, or `Z`, format specification processing stops. | -1 | `EILSEQ` (42) | No |
+| Encoding error during formatting | If processing character specifier `c` or `C`, the invalid character is skipped. The number of characters written isn't incremented for the skipped character, nor is any data written for it. Processing the format specification continues after skipping the specifier with the encoding error. | The number of characters written, not including the terminating `NULL`. | `EILSEQ` (42) | No |
+| `buffer == NULL` and `sizeOfBuffer == 0` and `count == 0` | No data is written. | 0 | N/A | No |
+| `buffer == NULL` and either `sizeOfBuffer != 0` or `count != 0` | If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value. | -1 | `EINVAL` (22) | Yes |
+| `buffer != NULL` and `sizeOfBuffer == 0` | No data is written. | -1 | `EINVAL` (22) | Yes |
+| `count == 0`| A `NULL` is placed at the beginning of the buffer. | -1 | N/A | No |
+| `count < 0`| Unsafe: the value is treated as unsigned, likely creating a large value that results in overwriting the memory that follows the buffer. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `count < sizeOfBuffer` and `len <= count` | All of the data is written and a terminating `NULL` is appended. | The number of characters written. | N/A | No |
+| `count < sizeOfBuffer` and `len > count` | The first *`count`* characters are written and a terminating `NULL` is appended. | -1 | N/A | No |
+| `count >= sizeOfBuffer` and `len < sizeOfBuffer` | All of the data is written with a terminating `NULL`. | The number of characters written. | N/A | No |
+| `count >= sizeOfBuffer` and `len >= sizeOfBuffer` and `count != _TRUNCATE` | If execution continues after invalid parameter handler executes, sets `errno`, sets `buffer[0] == NULL`, and returns a negative value. | -1 | `ERANGE` (34) | Yes |
+| `count == _TRUNCATE` and `len >= sizeOfBuffer` | Writes as much of the string as fits in *`buffer`* and a terminating `NULL`. | -1 | N/A | No |
+| `count == _TRUNCATE` and `len < sizeOfBuffer` | Writes the entire string into *`buffer`* with a terminating `NULL`. | Number of characters written, not including the terminating `NULL`. | N/A | No |
+| `format == NULL` | No data is written. If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value. | -1 | `EINVAL` (22) | Yes |
+
+For information about these and other error codes, see [`_doserrno`, `errno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
> [!IMPORTANT]
> Ensure that *`format`* is not a user-defined string.
>
->
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
-**`_snwprintf_s`** is a wide-character version of **`_snprintf_s`**; the pointer arguments to **`_snwprintf_s`** are wide-character strings. Detection of encoding errors in **`_snwprintf_s`** might differ from the detection in **`_snprintf_s`**. **`_snwprintf_s`**, like **`swprintf_s`**, writes output to a string rather than to a destination of type `FILE`.
+**`_snwprintf_s`** is a wide-character version of **`_snprintf_s`**; the pointer arguments to **`_snwprintf_s`** are wide-character strings. Detection of encoding errors in **`_snwprintf_s`** might differ from that in **`_snprintf_s`**. **`_snwprintf_s`**, like **`swprintf_s`**, writes output to a string rather than to a destination of type **`FILE`**.
The versions of these functions with the **`_l`** suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
@@ -112,17 +136,17 @@ In C++, using these functions is simplified by template overloads; the overloads
### Generic-text routine mappings
-| `Tchar.h` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+|`Tchar.h` routine|`_UNICODE` and `_MBCS` not defined|`_MBCS` defined|`_UNICODE` defined|
|---|---|---|---|
-| `_sntprintf_s` | **`_snprintf_s`** | **`_snprintf_s`** | **`_snwprintf_s`** |
-| `_sntprintf_s_l` | **`_snprintf_s_l`** | **`_snprintf_s_l`** | **`_snwprintf_s_l`** |
+|**`_sntprintf_s`**|**`_snprintf_s`**|**`_snprintf_s`**|**`_snwprintf_s`**|
+|**`_sntprintf_s_l`**|**`_snprintf_s_l`**|**`_snprintf_s_l`**|**`_snwprintf_s_l`**|
## Requirements
-| Routine | Required header |
+|Routine|Required header|
|---|---|
-| **`_snprintf_s`**, **`_snprintf_s_l`** | `` |
-| **`_snwprintf_s`**, **`_snwprintf_s_l`** | `` or `` |
+|**`_snprintf_s`**, **`_snprintf_s_l`**|``|
+|**`_snwprintf_s`**, **`_snwprintf_s_l`**|`` or ``|
For more compatibility information, see [Compatibility](../compatibility.md).
diff --git a/docs/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md b/docs/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md
index 0d5234db5d..6043ec459e 100644
--- a/docs/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md
+++ b/docs/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md
@@ -1,7 +1,7 @@
---
title: "snprintf, _snprintf, _snprintf_l, _snwprintf, _snwprintf_l"
description: "API reference for snprintf, _snprintf, _snprintf_l, _snwprintf, and _snwprintf_; which write formatted data to a string."
-ms.date: "3/9/2021"
+ms.date: 06/27/2023
api_name: ["_snwprintf", "_snprintf", "_snprintf_l", "_snwprintf_l", "snprintf"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
@@ -22,12 +22,14 @@ int snprintf(
const char *format [,
argument] ...
);
+
int _snprintf(
char *buffer,
size_t count,
const char *format [,
argument] ...
);
+
int _snprintf_l(
char *buffer,
size_t count,
@@ -35,12 +37,14 @@ int _snprintf_l(
_locale_t locale [,
argument] ...
);
+
int _snwprintf(
wchar_t *buffer,
size_t count,
const wchar_t *format [,
argument] ...
);
+
int _snwprintf_l(
wchar_t *buffer,
size_t count,
@@ -48,6 +52,7 @@ int _snwprintf_l(
_locale_t locale [,
argument] ...
);
+
template
int _snprintf(
char (&buffer)[size],
@@ -55,6 +60,7 @@ int _snprintf(
const char *format [,
argument] ...
); // C++ only
+
template
int _snprintf_l(
char (&buffer)[size],
@@ -63,6 +69,7 @@ int _snprintf_l(
_locale_t locale [,
argument] ...
); // C++ only
+
template
int _snwprintf(
wchar_t (&buffer)[size],
@@ -70,6 +77,7 @@ int _snwprintf(
const wchar_t *format [,
argument] ...
); // C++ only
+
template
int _snwprintf_l(
wchar_t (&buffer)[size],
@@ -86,7 +94,7 @@ int _snwprintf_l(
Storage location for the output.
*`count`*\
-Maximum number of characters to store.
+Maximum number of characters to write. For the functions that take `wchar_t`, it's the maximum number of wide characters to write.
*`format`*\
Format-control string.
@@ -95,37 +103,61 @@ Format-control string.
Optional arguments.
*`locale`*\
-The locale to use.
+The locale to use to format the output.
For more information, see [Format specification syntax: `printf` and `wprintf` functions](../format-specification-syntax-printf-and-wprintf-functions.md).
## Return value
-Let **`len`** be the length of the formatted data string, not including the terminating null. Both **`len`** and **`count`** are the number of characters for **`snprintf`** and **`_snprintf`**, and the number of wide characters for **`_snwprintf`**.
+The number of characters that which would have been written to the buffer if `count` was ignored. The count doesn't include the terminating `NULL` character.
+
+Let **`len`** be the length of the formatted data string, not including the terminating `NULL`.\
+For all functions, if `len < count`, then **`len`** characters are stored in *`buffer`*, a null-terminator is appended, and the number of characters written, not including the terminating `NULL`, is returned.
-For all functions, if **`len`** < *`count`*, **`len`** characters are stored in *`buffer`*, a null-terminator is appended, and **`len`** is returned.
+The wide character versions of these functions return the number of wide characters written, not including the terminating `NULL`.
-The **`snprintf`** function truncates the output when **`len`** is greater than or equal to *`count`*, by placing a null-terminator at `buffer[count-1]`. The value returned is **`len`**, the number of characters that would have been output if *`count`* was large enough. The **`snprintf`** function returns a negative value if an encoding error occurs.
+See [Behavior summary](#behavior-summary) for details.
-For all functions other than **`snprintf`**, if **`len`** = *`count`*, **`len`** characters are stored in *`buffer`*, no null-terminator is appended, and **`len`** is returned. If **`len`** > *`count`*, *`count`* characters are stored in *`buffer`*, no null-terminator is appended, and a negative value is returned.
+## Remarks
-If *`buffer`* is a null pointer and *`count`* is zero, **`len`** is returned as the count of characters required to format the output, not including the terminating null. To make a successful call with the same *`argument`* and *`locale`* parameters, allocate a buffer holding at least **`len`** + 1 characters.
+Beginning with the UCRT in Visual Studio 2015 and Windows 10, **`snprintf`** is no longer identical to **`_snprintf`**. The **`snprintf`** behavior is now C99 standard conformant. The difference is that if you run out of buffer, `snprintf` null-terminates the end of the buffer and returns the number of characters that would have been required whereas `_snprintf` doesn't null-terminate the buffer and returns -1. Also, `_snprintf()` includes one more character in the output because it doesn't null-terminate the buffer.
-If *`buffer`* is a null pointer and *`count`* is nonzero, or if *`format`* is a null pointer, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, these functions return -1 and set `errno` to `EINVAL`.
+- **`snprintf`** and the **`_snprintf`** family of functions format and store *`count`* or fewer characters in *`buffer`*.
+- **`snprintf`** always stores a terminating `NULL` character, truncating the output if necessary.
+- If **`snprintf`** returns a value > *`count`* - 1, the output has been truncated.
+- The **`_snprintf`** family of functions only appends a terminating `NULL` character if the formatted string length is strictly less than *`count`* characters.
+- Each *`argument`* (if any) is converted and is output according to the corresponding format specification in *`format`*. The format consists of ordinary characters and has the same form and function as the *`format`* argument for [`printf`](printf-printf-l-wprintf-wprintf-l.md). If copying occurs between strings that overlap, the behavior is undefined.
-For information about these and other error codes, see [`errno`, `_doserrno`, `_sys_errlist, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
+### Behavior summary
-## Remarks
+For the following table:
-The **`snprintf`** function and the **`_snprintf`** family of functions format and store *`count`* or fewer characters in *`buffer`*. The **`snprintf`** function always stores a terminating null character, truncating the output if necessary. The **`_snprintf`** family of functions only appends a terminating null character if the formatted string length is strictly less than *`count`* characters. Each *`argument`* (if any) is converted and is output according to the corresponding format specification in *`format`*. The format consists of ordinary characters and has the same form and function as the *`format`* argument for [`printf`](printf-printf-l-wprintf-wprintf-l.md). If copying occurs between strings that overlap, the behavior is undefined.
+- Let `sizeOfBuffer` be the size of `buffer`. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+- Let `len` be the size of the formatted data. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+- Characters refer to `char` characters for functions that take a `char` buffer, and to `wchar_t` characters for functions that take a `wchar_t` buffer.
+- For more information about the invalid parameter handler, see [Parameter Validation](../../c-runtime-library/parameter-validation.md).
+
+| Condition | Behavior | Return value | `errno` | Invokes invalid parameter handler |
+|--|--|--|--|--|
+| Success | Writes the characters into the buffer using the specified format string. | The number of characters written. | N/A | No |
+| Encoding error during formatting | If processing string specifier `s`, `S`, or `Z`, format specification processing stops, a `NULL` is placed at the beginning of the buffer. | -1 | `EILSEQ` (42) | No |
+| Encoding error during formatting | If processing character specifier `c` or `C`, the invalid character is skipped. The number of characters written isn't incremented for the skipped character, nor is any data written for it. Processing the format specification continues after skipping the specifier with the encoding error. | The number of characters written, not including the terminating `NULL`. | `EILSEQ` (42) | No |
+| `buffer == NULL` and `count != 0` | If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value. | -1 | `EINVAL` (22) | Yes |
+| `count == 0` | The number of characters that would have been written, not including the terminating `NULL`. You can use this result to allocate sufficient buffer space for the string and a terminating `NULL`, and then call the function again to fill the buffer. | N/A | No |
+| `count < 0`| Unsafe: the value is treated as unsigned, likely creating a large value that results in overwriting the memory that follows the buffer. | The number of characters written | N/A | No |
+| `count < sizeOfBuffer` and `len <= count` | All of the data is written and a terminating `NULL` is appended. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `count < sizeOfBuffer` and `len > count` | The first *`count-1`* characters are written followed by a null-terminator. | The number of characters that would have been written had `count` matched the number of characters to output, not including the null-terminator. | N/A | No |
+| `count >= sizeOfBuffer` and `len < sizeOfBuffer` | All of the data is written with a terminating `NULL`. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `count >= sizeOfBuffer` and `len >= sizeOfBuffer` | Unsafe: Overwrites the memory that follows the buffer. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `format == NULL` | No data is written. If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value. | -1 | `EINVAL` (22) | Yes |
+
+For information about these and other error codes, see [`_doserrno`, `errno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
> [!IMPORTANT]
> Ensure that *`format`* is not a user-defined string. Because the **`_snprintf`** functions do not guarantee null termination—in particular, when the return value is *`count`*—make sure that they are followed by code that adds the null terminator. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
>
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with [`legacy_stdio_float_rounding.obj`](../link-options.md).
-Beginning with the UCRT in Visual Studio 2015 and Windows 10, **`snprintf`** is no longer identical to **`_snprintf`**. The **`snprintf`** function behavior is now C99 standard conformant.
-
**`_snwprintf`** is a wide-character version of **`_snprintf`**; the pointer arguments to **`_snwprintf`** are wide-character strings. Detection of encoding errors in **`_snwprintf`** might differ from the detection in **`_snprintf`**. **`_snwprintf`**, just like **`swprintf`**, writes output to a string instead of a destination of type `FILE`.
The versions of these functions that have the **`_l`** suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
diff --git a/docs/c-runtime-library/reference/sopen-s-wsopen-s.md b/docs/c-runtime-library/reference/sopen-s-wsopen-s.md
index d6e46d00ef..04f2bd984a 100644
--- a/docs/c-runtime-library/reference/sopen-s-wsopen-s.md
+++ b/docs/c-runtime-library/reference/sopen-s-wsopen-s.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _sopen_s, _wsopen_s"
title: "_sopen_s, _wsopen_s"
+description: "Learn more about: _sopen_s, _wsopen_s"
ms.date: 05/18/2022
api_name: ["_sopen_s", "_wsopen_s", "_o__sopen_s", "_o__wsopen_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CORECRT_IO/_sopen_s", "CORECRT_WIO/_wsopen_s", "TCHAR/_tsopen_s", "_sopen_s", "_wsopen_s", "_tsopen_s", "sopen_s", "wsopen_s"]
helpviewer_keywords: ["sopen_s function", "_wsopen_s function", "wsopen_s function", "opening files, for sharing", "files [C++], opening", "_sopen_s function", "files [C++], sharing"]
-ms.assetid: 059a0084-d08c-4973-9174-55e391b72aa2
---
# `_sopen_s`, `_wsopen_s`
@@ -29,7 +28,7 @@ errno_t _wsopen_s(
const wchar_t *filename,
int oflag,
int shflag,
- int pmode,
+ int pmode
);
```
@@ -95,7 +94,7 @@ The integer expression *`oflag`* is formed by combining one or more manifest con
| `_O_RDONLY` | Opens a file for reading only. Can't be specified with `_O_RDWR` or `_O_WRONLY`. |
| `_O_RDWR` | Opens a file for both reading and writing. Can't be specified with `_O_RDONLY` or `_O_WRONLY`. |
| `_O_SEQUENTIAL` | Specifies that caching is optimized for, but not restricted to, sequential access from disk. |
-| `_O_TEXT` | Opens a file in text (translated) mode. (For more information, see [Text and binary mode file I/O](../text-and-binary-mode-file-i-o.md) and [`fopen`](fopen-wfopen.md).) |
+| `_O_TEXT` | Opens a file in ANSI text (translated) mode. (For more information, see [Text and binary mode file I/O](../text-and-binary-mode-file-i-o.md) and [`fopen`](fopen-wfopen.md).) |
| `_O_TRUNC` | Opens a file and truncates it to zero length; the file must have write permission. Can't be specified with `_O_RDONLY`. `_O_TRUNC` used with `_O_CREAT` opens an existing file or creates a file. **Note:** The `_O_TRUNC` flag destroys the contents of the specified file. |
| `_O_WRONLY` | Opens a file for writing only. Can't be specified with `_O_RDONLY` or `_O_RDWR`. |
| `_O_U16TEXT` | Opens a file in Unicode UTF-16 mode. |
diff --git a/docs/c-runtime-library/reference/sopen-wsopen.md b/docs/c-runtime-library/reference/sopen-wsopen.md
index 9df104ac25..c3e9b3a0aa 100644
--- a/docs/c-runtime-library/reference/sopen-wsopen.md
+++ b/docs/c-runtime-library/reference/sopen-wsopen.md
@@ -88,7 +88,7 @@ The integer expression *`oflag`* is formed by combining one or more of the follo
| `_O_RDONLY` | Opens a file for reading only. Can't be specified with `_O_RDWR` or `_O_WRONLY`. |
| `_O_RDWR` | Opens a file for both reading and writing. Can't be specified with `_O_RDONLY` or `_O_WRONLY`. |
| `_O_SEQUENTIAL` | Specifies that caching is optimized for, but not restricted to, sequential access from disk. |
-| `_O_TEXT` | Opens a file in text (translated) mode. (For more information, see [Text and binary mode file I/O](../text-and-binary-mode-file-i-o.md) and [`fopen`](fopen-wfopen.md).) |
+| `_O_TEXT` | Opens a file in ANSI text (translated) mode. (For more information, see [Text and binary mode file I/O](../text-and-binary-mode-file-i-o.md) and [`fopen`](fopen-wfopen.md).) |
| `_O_TRUNC` | Opens a file and truncates it to zero length; the file must have write permission. Can't be specified with `_O_RDONLY`. `_O_TRUNC` used with `_O_CREAT` opens an existing file or creates a file. **Note:** The `_O_TRUNC` flag destroys the contents of the specified file. |
| `_O_WRONLY` | Opens a file for writing only. Can't be specified with `_O_RDONLY` or `_O_RDWR`. |
| `_O_U16TEXT` | Opens a file in Unicode UTF-16 mode. |
diff --git a/docs/c-runtime-library/reference/splitpath-wsplitpath.md b/docs/c-runtime-library/reference/splitpath-wsplitpath.md
index 216a8c9caa..f11ecc1e6d 100644
--- a/docs/c-runtime-library/reference/splitpath-wsplitpath.md
+++ b/docs/c-runtime-library/reference/splitpath-wsplitpath.md
@@ -1,18 +1,17 @@
---
-description: "Learn more about: _splitpath, _wsplitpath"
title: "_splitpath, _wsplitpath"
-ms.date: "4/2/2020"
+description: "Learn more about: _splitpath, _wsplitpath"
+ms.date: 11/30/2023
api_name: ["_wsplitpath", "_splitpath", "_o__splitpath", "_o__wsplitpath"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-filesystem-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["wsplitpath", "_splitpath", "splitpath", "_wsplitpath", "_tsplitpath"]
helpviewer_keywords: ["_splitpath function", "pathnames", "wsplitpath function", "splitpath function", "_wsplitpath function", "tsplitpath function", "path names", "_tsplitpath function"]
-ms.assetid: 32bd76b5-1385-4ee8-a64c-abcb541cd2e4
---
# `_splitpath`, `_wsplitpath`
-Break a path name into components. More secure versions of these functions are available, see [`_splitpath_s`, `_wsplitpath_s`](splitpath-s-wsplitpath-s.md).
+Break a path into components. For more secure versions of these functions are available, see [`_splitpath_s`, `_wsplitpath_s`](splitpath-s-wsplitpath-s.md).
## Syntax
@@ -42,19 +41,19 @@ Full path.
Drive letter, followed by a colon (**:**). You can pass `NULL` for this parameter if you don't need the drive letter.
*`dir`*\
-Directory path, including trailing slash. Forward slashes ( **/** ), backslashes ( **\\** ), or both may be used. You can pass `NULL` for this parameter if you don't need the directory path.
+Directory path, including trailing slash. Forward slashes (`/`), backslashes (`\`), or both may be used. Pass `NULL` for this parameter if you don't need the directory path.
*`fname`*\
-Base filename (no extension). You can pass `NULL` for this parameter if you don't need the filename.
+Base filename (no extension). Pass `NULL` for this parameter if you don't need the filename.
*`ext`*\
-Filename extension, including leading period (**.**). You can pass `NULL` for this parameter if you don't need the filename extension.
+Filename extension, including leading period (`.`). Pass `NULL` for this parameter if you don't need the filename extension.
## Remarks
The **`_splitpath`** function breaks a path into its four components. **`_splitpath`** automatically handles multibyte-character string arguments as appropriate, recognizing multibyte-character sequences according to the multibyte code page currently in use. **`_wsplitpath`** is a wide-character version of **`_splitpath`**; the arguments to **`_wsplitpath`** are wide-character strings. These functions behave identically otherwise.
-**Security Note** These functions incur a potential threat brought about by a buffer overrun problem. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns). More secure versions of these functions are available; see [`_splitpath_s`, `_wsplitpath_s`](splitpath-s-wsplitpath-s.md).
+**Security Note** These functions are subject to buffer overrun. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns). More secure versions of these functions are available; see [`_splitpath_s`, `_wsplitpath_s`](splitpath-s-wsplitpath-s.md).
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
@@ -81,7 +80,7 @@ If the full path doesn't contain a component (for example, a filename), **`_spli
You can pass `NULL` to **`_splitpath`** for any parameter other than *`path`* that you don't need.
-If *`path`* is `NULL`, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, `errno` is set to `EINVAL` and the function returns `EINVAL`.
+If *`path`* is `NULL`, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, `errno` is set to `EINVAL`.
## Requirements
diff --git a/docs/c-runtime-library/reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md b/docs/c-runtime-library/reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md
index 3f35c2902b..960c47657c 100644
--- a/docs/c-runtime-library/reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md
+++ b/docs/c-runtime-library/reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md
@@ -103,7 +103,7 @@ The number of characters written, or -1 if an error occurred. If *`buffer`* or *
The **`sprintf`** function formats and stores a series of characters and values in *`buffer`*. Each *`argument`* (if any) is converted and output according to the corresponding format specification in *`format`*. The format consists of ordinary characters and has the same form and function as the *`format`* argument for [`printf`](printf-printf-l-wprintf-wprintf-l.md). A null character is appended after the last character written. If copying occurs between strings that overlap, the behavior is undefined.
> [!IMPORTANT]
-> Using **`sprintf`**, there is no way to limit the number of characters written, which means that code using **`sprintf`** is susceptible to buffer overruns. Consider using the related function [`_snprintf`](snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md), which specifies a maximum number of characters to write to *`buffer`*, or use [`_scprintf`](scprintf-scprintf-l-scwprintf-scwprintf-l.md) to determine how large a buffer is required. Also, ensure that *`format`* is not a user-defined string.
+> Using **`sprintf`**, there is no way to limit the number of characters written, which means that code using **`sprintf`** is susceptible to buffer overruns. Consider using the related function [`snprintf`](snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md), which specifies a maximum number of characters to write to *`buffer`*, or use [`_scprintf`](scprintf-scprintf-l-scwprintf-scwprintf-l.md) to determine how large a buffer is required. Also, ensure that *`format`* is not a user-defined string.
>
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
diff --git a/docs/c-runtime-library/reference/sqrt-sqrtf-sqrtl.md b/docs/c-runtime-library/reference/sqrt-sqrtf-sqrtl.md
index a54fed2e1a..ef2221147e 100644
--- a/docs/c-runtime-library/reference/sqrt-sqrtf-sqrtl.md
+++ b/docs/c-runtime-library/reference/sqrt-sqrtf-sqrtl.md
@@ -97,4 +97,4 @@ The square root of 45.35 is 6.73
[`exp`, `expf`, `expl`](exp-expf.md)\
[`log`, `logf`, `log10`, `log10f`](log-logf-log10-log10f.md)\
[`pow`, `powf`, `powl`](pow-powf-powl.md)\
-[`_CIsqrt`](../cisqrt.md)\
+[`_CIsqrt`](../cisqrt.md)
diff --git a/docs/c-runtime-library/reference/stat-functions.md b/docs/c-runtime-library/reference/stat-functions.md
index 519e6bb5f0..b1a5efc58f 100644
--- a/docs/c-runtime-library/reference/stat-functions.md
+++ b/docs/c-runtime-library/reference/stat-functions.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: _stat, _stat32, _stat64, _stati64, _stat32i64, _stat64i32, _wstat, _wstat32, _wstat64, _wstati64, _wstat32i64, _wstat64i32"
title: "_stat, _stat32, _stat64, _stati64, _stat32i64, _stat64i32, _wstat, _wstat32, _wstat64, _wstati64, _wstat32i64, _wstat64i32"
-ms.date: "4/2/2020"
+description: "Learn more about: _stat, _stat32, _stat64, _stati64, _stat32i64, _stat64i32, _wstat, _wstat32, _wstat64, _wstati64, _wstat32i64, _wstat64i32"
+ms.date: "5/25/2023"
api_name: ["_wstat64", "_stati64", "_stat32", "_stat32i64", "_stat", "_wstati64", "_wstat32", "_wstat64i32", "_wstat", "_stat64", "_stat64i32", "_wstat32i64", "_o__stat32", "_o__stat32i64", "_o__stat64", "_o__stat64i32", "_o__wstat32", "_o__wstat32i64", "_o__wstat64", "_o__wstat64i32"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-filesystem-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["stat/_stat", "stat/_stat32", "stat/_stat32i64", "stat/_stat64", "stat/_stat64i32", "stat/_stati64", "stat/__stat64", "TCHAR/_tstat", "TCHAR/_tstat32", "TCHAR/_tstat32i64", "TCHAR/_tstat64", "TCHAR/_tstat64i32", "TCHAR/_tstati64", "stat/_wstat", "stat/_wstat32", "stat/_wstat32i64", "stat/_wstat64", "stat/_wstat64i32", "stat/_wstati64", "_stat", "_stat32", "_stat32i64", "_stat64", "_stat64i32", "_stati64", "__stat64", "_tstat", "_tstat32", "_tstat32i64", "_tstat64", "_tstat64i32", "_tstati64", "_wstat", "_wstat32", "_wstat32i64", "_wstat64", "_wstat64i32", "_wstati64", "stat", "stat32", "stat32i64", "stat64", "stat64i32", "stati64", "tstat", "tstat32", "tstat32i64", "tstat64", "tstat64i32", "tstati64", "wstat", "wstat32", "wstat32i64", "wstat64", "wstat64i32", "wstati64"]
helpviewer_keywords: ["files [C++], status information", "_stat function", "_wstat function", "_stat64i32 function", "tstat function", "_tstat64i32 function", "_stati64 function", "_stat64 function", "tstati64 function", "wstati64 function", "wstat64 function", "_wstat64i32 function", "_tstat32i64 function", "_stat32i64 function", "stat function", "status of files", "_tstat32 function", "tstat64 function", "_wstat64 function", "_tstat function", "_stat32 function", "wstat function", "_wstat32i64 function", "_tstati64 function", "_wstat32 function", "stat64 function", "stati64 function", "_wstati64 function", "_tstat64 function", "files [C++], getting status information"]
-ms.assetid: 99a75ae6-ff26-47ad-af70-5ea7e17226a5
---
# `_stat`, `_stat32`, `_stat64`, `_stati64`, `_stat32i64`, `_stat64i32`, `_wstat`, `_wstat32`, `_wstat64`, `_wstati64`, `_wstat32i64`, `_wstat64i32`
@@ -95,6 +94,7 @@ Variations of these functions support 32-bit or 64-bit time types, and 32-bit or
> [!NOTE]
> **`_wstat`** does not work with Windows Vista symbolic links. In these cases, **`_wstat`** will always report a file size of 0. **`_stat`** does work correctly with symbolic links.
+> The `_stat` family of functions use `CreateFile` in Visual Studio 2015, instead of `FindFirstFile` as in Visual Studio 2013 and earlier. This means that `_stat` on a path ending with a slash succeeds if the path refers to a directory, as opposed to before when the function would error with `errno` set to `ENOENT`.
This function validates its parameters. If either *`path`* or *`buffer`* is `NULL`, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md).
diff --git a/docs/c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md b/docs/c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md
index eb0c5010b0..e0cb870b10 100644
--- a/docs/c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md
+++ b/docs/c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s.md
@@ -1,14 +1,13 @@
---
title: "strerror_s, _strerror_s, _wcserror_s, __wcserror_s"
description: "Functions with security enhancements to get a system error message or print a user-supplied error message."
-ms.date: "09/25/2020"
+ms.date: 05/31/2023
api_name: ["__wcserror_s", "_strerror_s", "_wcserror_s", "strerror_s", "_o__strerror_s", "_o__wcserror_s", "_o_strerror_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-runtime-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["wcserror_s", "__wcserror_s", "_tcserror_s", "_wcserror_s", "tcserror_s", "strerror_s", "_strerror_s"]
helpviewer_keywords: ["__wcserror_s function", "error messages, printing", "tcserror_s function", "printing error messages", "strerror_s function", "_wcserror_s function", "_tcserror_s function", "_strerror_s function", "wcserror_s function", "error messages, getting"]
-ms.assetid: 9e5b15a0-efe1-4586-b7e3-e1d7c31a03d6
---
# `strerror_s`, `_strerror_s`, `_wcserror_s`, `__wcserror_s`
@@ -104,9 +103,9 @@ if (( _access( "datafile",2 )) == -1 )
}
```
-If *`strErrMsg`* is `NULL`, **`_strerror_s`** returns a string in *`buffer`* that contains the system error message for the last library call that produced an error. The error-message string is terminated by the newline character ('\n'). If *`strErrMsg`* isn't equal to `NULL`, then **`_strerror_s`** returns a string in *`buffer`* that contains (in order) your string message, a colon, a space, the system error message for the last library call that produced an error, and a newline character. Your string message can be, at most, 94 characters long.
+If *`strErrMsg`* is `NULL`, **`_strerror_s`** returns a string in *`buffer`* that contains the system error message for the last library call that produced an error. If *`strErrMsg`* isn't equal to `NULL`, then **`_strerror_s`** returns a string in *`buffer`* that contains (in order) your string message, a colon, a space, the system error message for the last library call that produced an error. Your string message can be, at most, 94 characters long.
-These functions truncate the error message if its length exceeds the size of the buffer - 1. The resulting string in *`buffer`* will always be null-terminated.
+These functions truncate the error message if its length exceeds the size of the buffer - 1. The resulting string in *`buffer`* is always null-terminated.
The actual error number for **`_strerror_s`** is stored in the variable [`errno`](../errno-doserrno-sys-errlist-and-sys-nerr.md). The system error messages are accessed through the variable [`_sys_errlist`](../errno-doserrno-sys-errlist-and-sys-nerr.md), which is an array of messages ordered by error number. **`_strerror_s`** accesses the appropriate error message by using the `errno` value as an index to the variable `_sys_errlist`. The value of the variable [`_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md) is defined as the maximum number of elements in the `_sys_errlist` array. To produce accurate results, call **`_strerror_s`** immediately after a library routine return with an error. Otherwise, subsequent calls to **`strerror_s`** or **`_strerror_s`** can overwrite the `errno` value.
diff --git a/docs/c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md b/docs/c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md
index 38efb38503..234fd6914f 100644
--- a/docs/c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md
+++ b/docs/c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md
@@ -1,14 +1,13 @@
---
title: "strerror, _strerror, _wcserror, __wcserror"
description: "Describes the Microsoft C Runtime Library (CRT) functions strerror, _strerror, _wcserror, and __wcserror."
-ms.date: "4/2/2020"
+ms.date: "5/31/2023"
api_name: ["strerror", "_strerror", "_wcserror", "__wcserror", "_o___wcserror", "_o__strerror", "_o__wcserror", "_o_strerror"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-runtime-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["__sys_errlist", "wcserror", "_strerror", "__wcserror", "strerror", "__sys_nerr", "_tcserror", "_wcserror", "tcserror"]
helpviewer_keywords: ["strerror function", "_strerror function", "__sys_errlist", "wcserror function", "error messages, printing", "__sys_nerr", "tcserror function", "printing error messages", "_wcserror function", "_tcserror function", "__wcserror function", "error messages, getting"]
-ms.assetid: 27b72255-f627-43c0-8836-bcda8b003e14
---
# `strerror`, `_strerror`, `_wcserror`, `__wcserror`
@@ -51,7 +50,7 @@ if (( _access( "datafile", 2 )) == -1 )
fprintf( stderr, _strerror(NULL) );
```
-If *`strErrMsg`* is passed as `NULL`, **`_strerror`** returns a pointer to a string. It contains the system error message for the last library call that produced an error. The error-message string is terminated by the newline character ('\n'). When *`strErrMsg`* isn't `NULL`, the string contains, in order: your *`strErrMsg`* string, a colon, a space, the system error message, and a newline character. Your string message can be, at most, 94 characters long, in either narrow (**`_strerror`**) or wide (**`__wcserror`**) characters.
+If *`strErrMsg`* is passed as `NULL`, **`_strerror`** returns a pointer to a string. It contains the system error message for the last library call that produced an error. If you call `__wcserror`, the error-message string is terminated by the newline character (`'\n'`). The other functions don't add `'\n'`. When *`strErrMsg`* isn't `NULL`, the string contains, in order: your *`strErrMsg`* string, a colon, a space, the system error message. Your string message can be, at most, 94 characters long, in either narrow (**`_strerror`**) or wide (**`__wcserror`**) characters.
The actual error number for **`_strerror`** is stored in the variable [`errno`](../errno-doserrno-sys-errlist-and-sys-nerr.md). To produce accurate results, call **`_strerror`** immediately after a library routine returns an error. Otherwise, later calls to library routines may overwrite the `errno` value.
diff --git a/docs/c-runtime-library/reference/strncat-strncat-l-wcsncat-wcsncat-l-mbsncat-mbsncat-l.md b/docs/c-runtime-library/reference/strncat-strncat-l-wcsncat-wcsncat-l-mbsncat-mbsncat-l.md
index 3ca626efc4..53ae6ad1df 100644
--- a/docs/c-runtime-library/reference/strncat-strncat-l-wcsncat-wcsncat-l-mbsncat-mbsncat-l.md
+++ b/docs/c-runtime-library/reference/strncat-strncat-l-wcsncat-wcsncat-l-mbsncat-mbsncat-l.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: strncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_l"
title: "strncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_l"
+description: "Learn more about: strncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_l"
ms.date: "1/20/2021"
api_name: ["strncat", "_strncat_l", "_mbsncat", "_mbsncat_l", "wcsncat", "wcsncat_l", "_o__mbsncat", "_o__mbsncat_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll", "api-ms-win-crt-string-l1-1-0.dll", "ntoskrnl.exe"]
@@ -184,4 +184,4 @@ You can see that `BadAppend` caused a buffer overrun.
[`_strset`, `_strset_l`, `_wcsset`, `_wcsset_l`, `_mbsset`, `_mbsset_l`](strset-strset-l-wcsset-wcsset-l-mbsset-mbsset-l.md)\
[`strspn`, `wcsspn`, `_mbsspn`, `_mbsspn_l`](strspn-wcsspn-mbsspn-mbsspn-l.md)\
[Locale](../locale.md)\
-[Interpretation of multibyte-character sequences](../interpretation-of-multibyte-character-sequences.md)\
+[Interpretation of multibyte-character sequences](../interpretation-of-multibyte-character-sequences.md)
diff --git a/docs/c-runtime-library/reference/strncnt-wcsncnt-mbsnbcnt-mbsnbcnt-l-mbsnccnt-mbsnccnt-l.md b/docs/c-runtime-library/reference/strncnt-wcsncnt-mbsnbcnt-mbsnbcnt-l-mbsnccnt-mbsnccnt-l.md
index 4ca437d019..2c9cdcfed2 100644
--- a/docs/c-runtime-library/reference/strncnt-wcsncnt-mbsnbcnt-mbsnbcnt-l-mbsnccnt-mbsnccnt-l.md
+++ b/docs/c-runtime-library/reference/strncnt-wcsncnt-mbsnbcnt-mbsnbcnt-l-mbsnccnt-mbsnccnt-l.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _strncnt, _wcsncnt, _mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_l"
title: "_strncnt, _wcsncnt, _mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_l"
+description: "Learn more about: _strncnt, _wcsncnt, _mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_l"
ms.date: "4/2/2020"
api_name: ["_mbsnbcnt_l", "_mbsnccnt", "_wcsncnt", "_strncnt", "_mbsnccnt_l", "_mbsnbcnt", "_o__mbsnbcnt", "_o__mbsnbcnt_l", "_o__mbsnccnt", "_o__mbsnccnt_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_mbsnbcnt", "wcsncnt", "_tcsnbcnt", "_mbsnccnt", "_ftcsnbcnt", "mbsnbcnt", "strncnt", "mbsnbcnt_l", "mbsnccnt_l", "mbsnccnt", "_strncnt", "_wcsncnt"]
helpviewer_keywords: ["_strncnt function", "_mbsnbcnt function", "_mbsnbcnt_l function", "_mbsnccnt_l function", "mbsnbcnt_l function", "mbsnbcnt function", "tcsnbcnt function", "mbsnccnt_l function", "strncnt function", "_tcsnbcnt function", "mbsnccnt function", "wcsncnt function", "_mbsnccnt function", "_wcsncnt function"]
-ms.assetid: 2a022e9e-a307-4acb-a66b-e56e5357f848
---
# `_strncnt`, `_wcsncnt`, `_mbsnbcnt`, `_mbsnbcnt_l`, `_mbsnccnt`, `_mbsnccnt_l`
@@ -105,8 +104,8 @@ For more compatibility information, see [Compatibility](../compatibility.md).
```C
// crt_mbsnbcnt.c
-#include
-#include
+#include
+#include
int main( void )
{
diff --git a/docs/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md b/docs/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md
index ddf9483e51..784bbae4d5 100644
--- a/docs/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md
+++ b/docs/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md
@@ -1,22 +1,23 @@
---
description: "Learn more about: strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l"
-title: "strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l"
+title: "strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l, _tcsncpy_s, _tcsncpy_s_l, _tcsnccpy_s, _tcsnccpy_s_l"
ms.date: "4/2/2020"
-api_name: ["_mbsncpy_s_l", "wcsncpy_s", "_strncpy_s_l", "strncpy_s", "_mbsncpy_s", "_wcsncpy_s_l", "_o__mbsncpy_s", "_o__mbsncpy_s_l", "_o_strncpy_s", "_o_wcsncpy_s"]
+api_name: ["_mbsncpy_s_l", "wcsncpy_s", "_strncpy_s_l", "strncpy_s", "_mbsncpy_s", "_wcsncpy_s_l", "_o__mbsncpy_s", "_o__mbsncpy_s_l", "_o_strncpy_s", "_o_wcsncpy_s", "_tcsnccpy_s", "_tcsnccpy_s_l", "_tcsncpy_s", "_tcsncpy_s_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll", "api-ms-win-crt-string-l1-1-0.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["_tcsncpy_s", "_wcsncpy_s_l", "strncpy_s", "_strncpy_s_l", "wcsncpy_s", "_tcsncpy_s_l"]
-helpviewer_keywords: ["_wcsncpy_s_l function", "_mbsnbcpy_s function", "_tcsncpy_s_l function", "mbsncpy_s function", "strncpy_s_l function", "_strncpy_s_l function", "strncpy_s function", "mbsncpy_s_l function", "wcsncpy_s function", "copying strings", "strings [C++], copying", "_mbsnbcpy_s_l function", "_tcsncpy_s function", "wcsncpy_s_l function"]
-ms.assetid: a971c800-94d1-4d88-92f3-a2fe236a4546
+f1_keywords: ["_tcsncpy_s", "_wcsncpy_s_l", "strncpy_s", "_strncpy_s_l", "wcsncpy_s", "_tcsncpy_s_l", "_tcsnccpy_s", "_tcsnccpy_s_l"]
+helpviewer_keywords: ["_wcsncpy_s_l function", "_mbsnbcpy_s function", "_tcsncpy_s_l function", "mbsncpy_s function", "strncpy_s_l function", "_strncpy_s_l function", "strncpy_s function", "mbsncpy_s_l function", "wcsncpy_s function", "_tcsnccpy_s function", "copying strings", "strings [C++], copying", "_mbsnbcpy_s_l function", "_tcsncpy_s function", "wcsncpy_s_l function", "_tcsnccpy_s_l function"]
---
-# `strncpy_s`, `_strncpy_s_l`, `wcsncpy_s`, `_wcsncpy_s_l`, `_mbsncpy_s`, `_mbsncpy_s_l`
+# `strncpy_s`, `_strncpy_s_l`, `wcsncpy_s`, `_wcsncpy_s_l`, `_mbsncpy_s`, `_mbsncpy_s_l`, `_tcsncpy_s`, `_tcsncpy_s_l`, `_tcsnccpy_s`, `_tcsnccpy_s_l`
Copies characters of one string to another. These versions of [`strncpy`, `_strncpy_l`, `wcsncpy`, `_wcsncpy_l`, `_mbsncpy`, `_mbsncpy_l`](strncpy-strncpy-l-wcsncpy-wcsncpy-l-mbsncpy-mbsncpy-l.md) have security enhancements, as described in [Security features in the CRT](../security-features-in-the-crt.md).
> [!IMPORTANT]
> **`_mbsncpy_s`** and **`_mbsncpy_s_l`** cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported in Universal Windows Platform apps](../../cppcx/crt-functions-not-supported-in-universal-windows-platform-apps.md).
+For `_tcsnccpy_s`, `_tcsnccpy_s_l`, `_tcsnccpy_s`, and `_tcsnccpy_s_l` see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -168,12 +169,16 @@ The debug library versions of these functions first fill the buffer with 0xFE. T
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
| `_tcsncpy_s` | **`strncpy_s`** | **`_mbsnbcpy_s`** | **`wcsncpy_s`** |
| `_tcsncpy_s_l` | **`_strncpy_s_l`** | **`_mbsnbcpy_s_l`** | **`_wcsncpy_s_l`** |
+| `_tcsnccpy_s` | **`strncpy_s`** | **`_mbsncpy_s`** | **`_wcsncpy_s`** |
+| `_tcsnccpy_s_l` | **`_strncpy_s_l`** | **`_mbsncpy_s_l`** | **`_wcsncpy_s_l`** |
> [!NOTE]
> **`_strncpy_s_l`**, **`_wcsncpy_s_l`** and **`_mbsncpy_s_l`** have no locale dependence. They're provided just for `_tcsncpy_s_l` and aren't intended to be called directly.
diff --git a/docs/c-runtime-library/reference/strnset-s-strnset-s-l-wcsnset-s-wcsnset-s-l-mbsnset-s-mbsnset-s-l.md b/docs/c-runtime-library/reference/strnset-s-strnset-s-l-wcsnset-s-wcsnset-s-l-mbsnset-s-mbsnset-s-l.md
index 61f514871a..e7d55e8de2 100644
--- a/docs/c-runtime-library/reference/strnset-s-strnset-s-l-wcsnset-s-wcsnset-s-l-mbsnset-s-mbsnset-s-l.md
+++ b/docs/c-runtime-library/reference/strnset-s-strnset-s-l-wcsnset-s-wcsnset-s-l-mbsnset-s-mbsnset-s-l.md
@@ -1,22 +1,23 @@
---
description: "Learn more about: _strnset_s, _strnset_s_l, _wcsnset_s, _wcsnset_s_l, _mbsnset_s, _mbsnset_s_l"
-title: "_strnset_s, _strnset_s_l, _wcsnset_s, _wcsnset_s_l, _mbsnset_s, _mbsnset_s_l"
+title: "_strnset_s, _strnset_s_l, _wcsnset_s, _wcsnset_s_l, _mbsnset_s, _mbsnset_s_l, _tcsnset_s, _tcsncset_s, _tcsncset_s_l"
ms.date: "4/2/2020"
-api_name: ["_mbsnset_s_l", "_strnset_s", "_mbsnset_s", "_strnset_s_l", "_wcsnset_s_l", "_wcsnset_s", "_o__mbsnset_s", "_o__mbsnset_s_l", "_o__strnset_s", "_o__wcsnset_s"]
+api_name: ["_mbsnset_s_l", "_strnset_s", "_mbsnset_s", "_strnset_s_l", "_wcsnset_s_l", "_wcsnset_s", "_o__mbsnset_s", "_o__mbsnset_s_l", "_o__strnset_s", "_o__wcsnset_s", "_tcsncset_s", "_tcsncset_s_l", "_tcsnset_s"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll", "api-ms-win-crt-string-l1-1-0.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["_mbsnset_s_l", "wcsnset_s", "_tcsnset_s_l", "_wcsnset_s", "_mbsnset_s", "_wcsnset_s_l", "_strnset_s_l", "strnset_s_l", "_tcsnset_s", "_strnset_s", "strnset_s", "mbsnset_s_l", "mbsnset_s", "wcsnset_s_l"]
-helpviewer_keywords: ["tcsnset_s function", "mbsnset_s_l function", "initializing characters", "wcsnset_s function", "mbsnset_s function", "_tcsnset_s_l function", "_strnset_s_l function", "_mbsnset_s function", "strnset_s_l function", "_tcsnset_s function", "_strnset_s function", "tcsnset_s_l function", "_mbsnset_s_l function", "strnset_s function", "_wcsnset_s function"]
-ms.assetid: 9cf1b321-b5cb-4469-b285-4c07cfbd8813
+f1_keywords: ["_mbsnset_s_l", "wcsnset_s", "_tcsnset_s", "_tcsnset_s_l", "_wcsnset_s", "_mbsnset_s", "_wcsnset_s_l", "_strnset_s_l", "strnset_s_l", "_strnset_s", "strnset_s", "mbsnset_s_l", "mbsnset_s", "wcsnset_s_l", "_tcsncset_s", "_tcsncset_s_l"]
+helpviewer_keywords: ["tcsnset_s function", "mbsnset_s_l function", "initializing characters", "wcsnset_s function", "mbsnset_s function", "_tcsnset_s function", "_tcsnset_s_l function", "_strnset_s_l function", "_mbsnset_s function", "strnset_s_l function", "_strnset_s function", "tcsnset_s_l function", "_mbsnset_s_l function", "strnset_s function", "_wcsnset_s function", "_tcsncset_s function", "_tcsncset_s_l function"]
---
-# `_strnset_s`, `_strnset_s_l`, `_wcsnset_s`, `_wcsnset_s_l`, `_mbsnset_s`, `_mbsnset_s_l`
+# `_strnset_s`, `_strnset_s_l`, `_wcsnset_s`, `_wcsnset_s_l`, `_mbsnset_s`, `_mbsnset_s_l`, `_tcsnset_s`, `_tcsncset_s`, `_tcsncset_s_l`
Initializes characters of a string to a given character. These versions of [`_strnset`, `_strnset_l`, `_wcsnset`, `_wcsnset_l`, `_mbsnset`, `_mbsnset_l`](strnset-strnset-l-wcsnset-wcsnset-l-mbsnset-mbsnset-l.md) have security enhancements, as described in [Security features in the CRT](../security-features-in-the-crt.md).
> [!IMPORTANT]
> **`_mbsnset_s`** and **`_mbsnset_s_l`** cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported in Universal Windows Platform apps](../../cppcx/crt-functions-not-supported-in-universal-windows-platform-apps.md).
+For `_tcsnset_s`, `_tcsnset_s_l`, `_tcsncset_s`, and `_tcsncset_s_l` see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -92,26 +93,30 @@ These functions set, at most, the first *`count`* characters of *`str`* to *`c`*
The output value is affected by the setting of the `LC_CTYPE` category setting of the locale. For more information, see [`setlocale`](setlocale-wsetlocale.md). The versions of these functions without the `_l` suffix use the current locale for this locale-dependent behavior; the versions with the `_l` suffix are identical except that they use the locale parameter passed in instead. For more information, see [Locale](../locale.md).
-The debug library versions of these functions first fill the buffer with 0xFE. To disable this behavior, use [`_CrtSetDebugFillThreshold`](crtsetdebugfillthreshold.md).
+The debug library versions of these functions first fill the buffer with `0xFE`. To disable this behavior, use [`_CrtSetDebugFillThreshold`](crtsetdebugfillthreshold.md).
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| TCHAR.H routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` function | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
-| `_tcsnset_s` | **`_strnset_s`** | **`_mbsnbset_s`** | **`_wcsnset_s`** |
-| `_tcsnset_s_l` | **`_strnset_s_l`** | **`_mbsnbset_s_l`** | **`_wcsnset_s_l`** |
+| `_tcsnset_s` | `_strnset_s` | `_mbsnbset_s` | `_wcsnset_s` |
+| `_tcsnset_s_l` | `_strnset_s_l` | `_mbsnbset_s_l` | `_wcsnset_s_l` |
+| `_tcsncset_s` | `_strnset_s` | `_mbsnset_s` | `_wcsnset_s` |
+| `_tcsncset_s_l` | `_strnset_s_l` | `_mbsnset_s_l` | `_wcsnset_s_l` |
## Requirements
| Routine | Required header |
|---|---|
-| **`_strnset_s`** | \ |
-| **`_strnset_s_l`** | \ |
-| **`_wcsnset_s`** | \ or \ |
-| **`_wcsnset_s_l`** | \ |
-| **`_mbsnset_s`**, **`_mbsnset_s_l`** | \ |
+| **`_strnset_s`** | `` |
+| **`_strnset_s_l`** | `` |
+| **`_wcsnset_s`** | `` or `` |
+| **`_wcsnset_s_l`** | `` |
+| **`_mbsnset_s`**, **`_mbsnset_s_l`** | `` |
For more compatibility information, see [Compatibility](../compatibility.md).
diff --git a/docs/c-runtime-library/reference/strrchr-wcsrchr-mbsrchr-mbsrchr-l.md b/docs/c-runtime-library/reference/strrchr-wcsrchr-mbsrchr-mbsrchr-l.md
index 90ada77650..9c8d760c68 100644
--- a/docs/c-runtime-library/reference/strrchr-wcsrchr-mbsrchr-mbsrchr-l.md
+++ b/docs/c-runtime-library/reference/strrchr-wcsrchr-mbsrchr-mbsrchr-l.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: strrchr, wcsrchr, _mbsrchr, _mbsrchr_l"
title: "strrchr, wcsrchr, _mbsrchr, _mbsrchr_l"
+description: "Learn more about: strrchr, wcsrchr, _mbsrchr, _mbsrchr_l"
ms.date: "4/2/2020"
api_name: ["strrchr", "wcsrchr", "_mbsrchr", "_mbsrchr_l", "_o__mbsrchr", "_o__mbsrchr_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ntdll.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll", "ntoskrnl.exe"]
@@ -131,4 +131,4 @@ For an example of using **`strrchr`**, see [`strchr`](strchr-wcschr-mbschr-mbsch
[`strcspn`, `wcscspn`, `_mbscspn`, `_mbscspn_l`](strcspn-wcscspn-mbscspn-mbscspn-l.md)\
[`_strnicmp`, `_wcsnicmp`, `_mbsnicmp`, `_strnicmp_l`, `_wcsnicmp_l`, `_mbsnicmp_l`](strnicmp-wcsnicmp-mbsnicmp-strnicmp-l-wcsnicmp-l-mbsnicmp-l.md)\
[`strpbrk`, `wcspbrk`, `_mbspbrk`, `_mbspbrk_l`](strpbrk-wcspbrk-mbspbrk-mbspbrk-l.md)\
-[`strspn`, `wcsspn`, `_mbsspn`, `_mbsspn_l`](strspn-wcsspn-mbsspn-mbsspn-l.md)\
+[`strspn`, `wcsspn`, `_mbsspn`, `_mbsspn_l`](strspn-wcsspn-mbsspn-mbsspn-l.md)
diff --git a/docs/c-runtime-library/reference/strtoimax-strtoimax-l-wcstoimax-wcstoimax-l.md b/docs/c-runtime-library/reference/strtoimax-strtoimax-l-wcstoimax-wcstoimax-l.md
index c6bcf88b3f..288b4dcce8 100644
--- a/docs/c-runtime-library/reference/strtoimax-strtoimax-l-wcstoimax-wcstoimax-l.md
+++ b/docs/c-runtime-library/reference/strtoimax-strtoimax-l-wcstoimax-wcstoimax-l.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: strtoimax, _strtoimax_l, wcstoimax, _wcstoimax_l"
title: "strtoimax, _strtoimax_l, wcstoimax, _wcstoimax_l"
-ms.date: "11/04/2016"
+description: "Learn more about: strtoimax, _strtoimax_l, wcstoimax, _wcstoimax_l"
+ms.date: 11/04/2016
api_name: ["wcstoimax", "_wcstoimax_l", "_strtoimax_l", "strtoimax"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-convert-l1-1-0.dll"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["wcstoimax", "_tcstoimax", "strtoimax", "_wcstoimax_l", "_strtoimax_l", "_tcstoimax_l"]
-helpviewer_keywords: ["strtoimax funciton", "conversion functions", "_strtoimax_l function", "_wcstoimax_l function", "wcstoimax function"]
-ms.assetid: 4530d3dc-aaac-4a76-b7cf-29ae3c98d0ae
+helpviewer_keywords: ["strtoimax function", "conversion functions", "_strtoimax_l function", "_wcstoimax_l function", "wcstoimax function"]
---
# `strtoimax`, `_strtoimax_l`, `wcstoimax`, `_wcstoimax_l`
diff --git a/docs/c-runtime-library/reference/toupper-toupper-towupper-toupper-l-towupper-l.md b/docs/c-runtime-library/reference/toupper-toupper-towupper-toupper-l-towupper-l.md
index 117c02ee05..0e89d73c47 100644
--- a/docs/c-runtime-library/reference/toupper-toupper-towupper-toupper-l-towupper-l.md
+++ b/docs/c-runtime-library/reference/toupper-toupper-towupper-toupper-l-towupper-l.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CTYPE/toupper", "CTYPE/_toupper", "CTYPE/_toupper_l", "CORECRT_WCTYPE/towupper", "CORECRT_WCTYPE/_towupper_l", "TCHAR/_totupper", "TCHAR/_totupper_l", "toupper", "_toupper", "_toupper_l", "towupper", "_towupper_l", "_totupper", "_totupper_l"]
helpviewer_keywords: ["_toupper function", "towupper function", "uppercase, converting strings to", "totupper function", "string conversion, to different characters", "towupper_l function", "toupper_l function", "string conversion, case", "_toupper_l function", "_towupper_l function", "_totupper function", "case, converting", "characters, converting", "toupper function"]
-ms.assetid: cdef1b0f-b19c-4d11-b7d2-cf6334c9b6cc
---
# `toupper`, `_toupper`, `towupper`, `_toupper_l`, `_towupper_l`
@@ -52,19 +51,17 @@ If *`c`* is a wide character for which `iswlower` is nonzero and there's a corre
There's no return value reserved to indicate an error.
-In order for **`toupper`** to give the expected results, [`__isascii`](isascii-isascii-iswascii.md) and [`islower`](islower-iswlower-islower-l-iswlower-l.md) must both return nonzero.
-
## Remarks
Each of these routines converts a given lowercase letter to an uppercase letter if possible and appropriate. The case conversion of **`towupper`** is locale-specific. Only the characters relevant to the current locale are changed in case. The functions without the `_l` suffix use the currently set locale. The versions of these functions with the `_l` suffix take the locale as a parameter and use that instead of the currently set locale. For more information, see [Locale](../locale.md).
-In order for **`toupper`** to give the expected results, [`__isascii`](isascii-isascii-iswascii.md) and [`isupper`](isupper-isupper-l-iswupper-iswupper-l.md) must both return nonzero.
+For **`toupper`** to give the expected results, [`__isascii`](isascii-isascii-iswascii.md) must return nonzero.
By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md).
### Generic-text routine mappings
-| TCHAR.H routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
| `_totupper` | **`toupper`** | **`_mbctoupper`** | **`towupper`** |
| `_totupper_l` | **`_toupper_l`** | **`_mbctoupper_l`** | **`_towupper_l`** |
diff --git a/docs/c-runtime-library/reference/ungetc-nolock-ungetwc-nolock.md b/docs/c-runtime-library/reference/ungetc-nolock-ungetwc-nolock.md
index d1fd1cff63..eba0a2a049 100644
--- a/docs/c-runtime-library/reference/ungetc-nolock-ungetwc-nolock.md
+++ b/docs/c-runtime-library/reference/ungetc-nolock-ungetwc-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _ungetc_nolock, _ungetwc_nolock"
title: "_ungetc_nolock, _ungetwc_nolock"
+description: "Learn more about: _ungetc_nolock, _ungetwc_nolock"
ms.date: "4/2/2020"
api_name: ["_ungetwc_nolock", "_ungetc_nolock", "_o__ungetc_nolock", "_o__ungetwc_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-stdio-l1-1-0.dll"]
@@ -8,11 +8,10 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["STDIO/_ungetc_nolock", "CORECRT_WSTDIO/_ungetwc_nolock", "TCHAR/_ungettc_nolock", "_ungetc_nolock", "_ungetwc_nolock", "_ungettc_nolock"]
helpviewer_keywords: ["_ungettc_nolock function", "_ungetwc_nolock function", "characters, pushing back onto stream", "_ungetc_nolock function", "ungetwc_nolock function", "ungettc_nolock function", "ungetc_nolock function"]
-ms.assetid: aa02d5c2-1be1-46d2-a8c4-b61269e9d465
---
# `_ungetc_nolock`, `_ungetwc_nolock`
-Pushes a character back onto the stream.
+Pushes a character back onto the stream without locking.
## Syntax
diff --git a/docs/c-runtime-library/reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md b/docs/c-runtime-library/reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md
index aaec9dbe4d..5c15bfbf42 100644
--- a/docs/c-runtime-library/reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md
+++ b/docs/c-runtime-library/reference/ungetch-ungetwch-ungetch-nolock-ungetwch-nolock.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _ungetch, _ungetwch, _ungetch_nolock, _ungetwch_nolock"
title: "_ungetch, _ungetwch, _ungetch_nolock, _ungetwch_nolock"
+description: "Learn more about: _ungetch, _ungetwch, _ungetch_nolock, _ungetwch_nolock"
ms.date: "4/2/2020"
api_name: ["_ungetch_nolock", "_ungetwch_nolock", "_ungetwch", "_ungetch", "_o__ungetch", "_o__ungetch_nolock", "_o__ungetwch", "_o__ungetwch_nolock"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-conio-l1-1-0.dll"]
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["CONIO/_ungetch", "CONIO/_ungetch_nolock", "CORECRT_WCONIO/_ungetwch", "CORECRT_WCONIO/_ungetwch_nolock", "TCHAR/_ungettch", "TCHAR/_ungettch_nolock", "_ungetch", "_ungetch_nolock", "_ungetwch", "_ungetwch_nolock", "_ungettch", "_ungettch_nolock"]
helpviewer_keywords: ["_ungetch function", "ungetwch function", "characters, pushing back to console", "_ungettch_nolock function", "ungettch function", "_ungettch function", "ungetch_nolock function", "ungettch_nolock function", "_ungetwch_nolock function", "_ungetch_nolock function", "ungetwch_nolock function", "_ungetwch function"]
-ms.assetid: 70ae71c6-228c-4883-a57d-de6d5f873825
---
# `_ungetch`, `_ungetwch`, `_ungetch_nolock`, `_ungetwch_nolock`
diff --git a/docs/c-runtime-library/reference/vscprintf-p-vscprintf-p-l-vscwprintf-p-vscwprintf-p-l.md b/docs/c-runtime-library/reference/vscprintf-p-vscprintf-p-l-vscwprintf-p-vscwprintf-p-l.md
index fecfe00e8c..6f6910fcf6 100644
--- a/docs/c-runtime-library/reference/vscprintf-p-vscprintf-p-l-vscwprintf-p-vscwprintf-p-l.md
+++ b/docs/c-runtime-library/reference/vscprintf-p-vscprintf-p-l-vscwprintf-p-vscwprintf-p-l.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: _vscprintf_p, _vscprintf_p_l, _vscwprintf_p, _vscwprintf_p_l"
title: "_vscprintf_p, _vscprintf_p_l, _vscwprintf_p, _vscwprintf_p_l"
+description: "Learn more about: _vscprintf_p, _vscprintf_p_l, _vscwprintf_p, _vscwprintf_p_l"
ms.date: "10/21/2021"
api_name: ["_vscprintf_p_l", "_vscprintf_p", "_vscwprintf_p_l", "_vscwprintf_p"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll"]
@@ -59,6 +59,9 @@ These functions differ from **`_vscprintf`** and **`_vscwprintf`** only in that
The versions of these functions with the **`_l`** suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
+Return Value is the size of the formatted data. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+Characters refer to `char` characters for functions that take a `char` buffer, and to `wchar_t` characters for functions that take a `wchar_t` buffer.
+
If *`format`* is a null pointer, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, the functions return -1 and set `errno` to `EINVAL`.
> [!IMPORTANT]
@@ -89,4 +92,4 @@ See the example for [`vsprintf`](vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswpr
[`vprintf` functions](../vprintf-functions.md)\
[`_scprintf_p`, `_scprintf_p_l`, `_scwprintf_p`, `_scwprintf_p_l`](scprintf-p-scprintf-p-l-scwprintf-p-scwprintf-p-l.md)\
-[`_vscprintf`, `_vscprintf_l`, `_vscwprintf`, `_vscwprintf_l`](vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md)\
+[`_vscprintf`, `_vscprintf_l`, `_vscwprintf`, `_vscwprintf_l`](vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md)
diff --git a/docs/c-runtime-library/reference/vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md b/docs/c-runtime-library/reference/vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md
index 080aed3268..ac02613e06 100644
--- a/docs/c-runtime-library/reference/vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md
+++ b/docs/c-runtime-library/reference/vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md
@@ -59,6 +59,9 @@ If *`format`* is a null pointer, the invalid parameter handler is invoked, as de
## Remarks
+Return Value is the size of the formatted data. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+Characters refer to `char` characters for functions that take a `char` buffer, and to `wchar_t` characters for functions that take a `wchar_t` buffer.
+
Each *`argument`* (if any) is converted according to the corresponding format specification in *`format`*. The format consists of ordinary characters and has the same form and function as the *`format`* argument for [`printf`](printf-printf-l-wprintf-wprintf-l.md).
> [!IMPORTANT]
diff --git a/docs/c-runtime-library/reference/vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l.md b/docs/c-runtime-library/reference/vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l.md
index 4e0485e783..096bc62882 100644
--- a/docs/c-runtime-library/reference/vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l.md
+++ b/docs/c-runtime-library/reference/vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l.md
@@ -1,7 +1,7 @@
---
description: "Learn more about: vsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_l"
title: "vsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_l"
-ms.date: 09/29/2022
+ms.date: 06/27/2023
api_name: ["_vsnwprintf_s", "_vsnwprintf_s_l", "_vsnprintf_s", "vsnprintf_s", "_vsnprintf_s_l"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ntdll.dll", "ucrtbase.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
@@ -23,6 +23,7 @@ int vsnprintf_s(
const char *format,
va_list argptr
);
+
int _vsnprintf_s(
char *buffer,
size_t sizeOfBuffer,
@@ -30,6 +31,7 @@ int _vsnprintf_s(
const char *format,
va_list argptr
);
+
int _vsnprintf_s_l(
char *buffer,
size_t sizeOfBuffer,
@@ -38,6 +40,7 @@ int _vsnprintf_s_l(
_locale_t locale,
va_list argptr
);
+
int _vsnwprintf_s(
wchar_t *buffer,
size_t sizeOfBuffer,
@@ -45,6 +48,7 @@ int _vsnwprintf_s(
const wchar_t *format,
va_list argptr
);
+
int _vsnwprintf_s_l(
wchar_t *buffer,
size_t sizeOfBuffer,
@@ -53,6 +57,7 @@ int _vsnwprintf_s_l(
_locale_t locale,
va_list argptr
);
+
template
int _vsnprintf_s(
char (&buffer)[size],
@@ -60,6 +65,7 @@ int _vsnprintf_s(
const char *format,
va_list argptr
); // C++ only
+
template
int _vsnwprintf_s(
wchar_t (&buffer)[size],
@@ -75,10 +81,10 @@ int _vsnwprintf_s(
Storage location for output.
*`sizeOfBuffer`*\
-The size of the *`buffer`* for output, as the character count.
+The size of the *`buffer`* for output. Size in **bytes** for the functions that take `char`, and **words** for those that take `wchar_t`.
*`count`*\
-Maximum number of characters to write (not including the terminating null), or [`_TRUNCATE`](../truncate.md).
+Maximum number of characters to write not including the terminating `NULL`. For the functions that take `wchar_t`, it's the number of wide characters to write. Or [`_TRUNCATE`](../truncate.md).
*`format`*\
Format specification.
@@ -87,51 +93,61 @@ Format specification.
Pointer to list of arguments.
*`locale`*\
-The locale to use.
+The locale to use when formatting the output.
For more information, see [Format specifications](../format-specification-syntax-printf-and-wprintf-functions.md).
## Return value
-**`vsnprintf_s`**, **`_vsnprintf_s`** and **`_vsnwprintf_s`** return the number of characters written, not including the terminating null, or a negative value if either truncation of the data or an output error occurs.
-
-* If *`count`* is less than *`sizeOfBuffer`* and the number of characters of data is less than or equal to *`count`*, or *`count`* is [`_TRUNCATE`](../truncate.md) and the number of characters of data is less than *`sizeOfBuffer`*, then all of the data is written and the number of characters is returned.
-
-* If *`count`* is less than *`sizeOfBuffer`* but the data exceeds *`count`* characters, then the first *`count`* characters are written. Truncation of the remaining data occurs and -1 is returned without invoking the invalid parameter handler.
+The number of characters written, not including the terminating `NULL`, or a negative value if an output error occurs.
-* If *`count`* is [`_TRUNCATE`](../truncate.md) and the number of characters of data equals or exceeds *`sizeOfBuffer`*, then as much of the string as will fit in *`buffer`* (with terminating null) is written. Truncation of the remaining data occurs and -1 is returned without invoking the invalid parameter handler.
-
-* If *`count`* is equal to or exceeds *`sizeOfBuffer`* but the number of characters of data is less than *`sizeOfBuffer`*, then all of the data is written (with terminating null) and the number of characters is returned.
-
-* If *`count`* and the number of characters of data both equal or exceed *`sizeOfBuffer`*, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution continues after the invalid parameter handler, these functions set *`buffer`* to an empty string, set `errno` to `ERANGE`, and return -1.
-
-* If *`buffer`* or *`format`* is a `NULL` pointer, or if *`count`* is less than or equal to zero, the invalid parameter handler is invoked. If execution is allowed to continue, these functions set `errno` to `EINVAL` and return -1.
-
-### Error conditions
-
-| Condition | Return value | `errno` |
-|---|---|---|
-| *`buffer`* is `NULL` | -1 | `EINVAL` |
-| *`format`* is `NULL` | -1 | `EINVAL` |
-| *`count`* <= 0 | -1 | `EINVAL` |
-| *`sizeOfBuffer`* too small (and *`count`* != `_TRUNCATE`) | -1 (and *`buffer`* set to an empty string) | `ERANGE` |
+See [Behavior summary](#behavior-summary) for details.
## Remarks
-**`vsnprintf_s`** is identical to **`_vsnprintf_s`**. **`vsnprintf_s`** is included for conformance to the ANSI standard. **`_vnsprintf`** is retained for backward compatibility.
+Each of these functions takes a pointer to an argument list, then formats and writes up to *`count`* characters of the given data to the memory pointed to by *`buffer`* and appends a terminating `NULL`.
-Each of these functions takes a pointer to an argument list, then formats and writes up to *`count`* characters of the given data to the memory pointed to by *`buffer`* and appends a terminating null.
-
-If *`count`* is [`_TRUNCATE`](../truncate.md), then these functions write as much of the string as will fit in *`buffer`* while leaving room for a terminating null. If the entire string (with terminating null) fits in *`buffer`*, then these functions return the number of characters written (not including the terminating null); otherwise, these functions return -1 to indicate that truncation occurred.
+In debug builds, the remaining `sizeOfBuffer` bytes following the terminating `NULL` are filled with 'xFE' as described in [`_CrtSetDebugFillThreshold`](crtsetdebugfillthreshold.md).
The versions of these functions with the **`_l`** suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
+**`vsnprintf_s`** is identical to **`_vsnprintf_s`** and is included for conformance to the ANSI standard. **`_vnsprintf`** is retained for backward compatibility.
+
+### Behavior summary
+
+For the following table:
+
+- Let `len` be the size of the formatted data. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+- Characters refer to `char` characters for functions that take a `char` buffer, and to `wchar_t` characters for functions that take a `wchar_t` buffer.
+- For more information about the invalid parameter handler, see [Parameter Validation](../../c-runtime-library/parameter-validation.md).
+
+| Condition | Behavior | Return value | `errno` | Invokes invalid parameter handler|
+|--|--|--|--|--|
+| Success | Writes the characters into the buffer using the specified format string | The number of characters written | N/A | No |
+| Encoding error during formatting | If processing string specifier `s`, `S`, or `Z`, format specification processing stops. | -1 | `EILSEQ (42)` | No |
+| Encoding error during formatting | If processing character specifier `c` or `C`, the invalid character is skipped. The number of characters written isn't incremented for the skipped character, nor is any data written for it. Processing the format specification continues after skipping the specifier with the encoding error. | The number of characters written, not including the terminating `NULL`. | `EILSEQ (42)` | No |
+| `buffer == NULL` and `sizeOfBuffer == 0` and `count == 0` | No data is written. | 0 | N/A | No |
+| `buffer == NULL` and either `sizeOfBuffer != 0` or `count != 0` | If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value.| -1 | `EINVAL` (22) | Yes |
+| `buffer != NULL` and `sizeOfBuffer == 0` | No data is written. If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value. | -1 | `EINVAL` (22) | Yes |
+| `buffer != NULL` and `sizeOfBuffer != 0` and `count == 0` | The buffer is `NULL` terminated. | -1 | N/A | No |
+| `count == 0`| Doesn't write any data and returns the number of characters that would have been written, not including the terminating `NULL`. | The number of characters that would have been written not including the terminating `NULL`. | N/A | No |
+| `count < 0` | Unsafe: the value is treated as unsigned, likely creating a large value that results in overwriting the memory that follows the buffer. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `count < sizeOfBuffer` and `len <= count` | All of the data is written and a terminating `NULL` is appended. | The number of characters written. | N/A | No |
+| `count < sizeOfBuffer` and `len > count` | The first *`count`* characters are written. | -1 | N/A | No |
+| `count >= sizeOfBuffer` and `len < sizeOfBuffer` | All of the data is written with a terminating `NULL`. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `count >= sizeOfBuffer` and `len >= sizeOfBuffer` and `count != _TRUNCATE` | If execution continues after invalid parameter handler executes, sets `errno`, sets `buffer[0] == NULL`, and returns a negative value. | -1 | `ERANGE` (34) | Yes |
+| `count == _TRUNCATE` and `len >= sizeOfBuffer` | Writes as much of the string as fits in *`buffer`*, including the terminating `NULL`. | -1 | N/A | No |
+| `count == _TRUNCATE` and `len < sizeOfBuffer` | Writes the entire string into *`buffer`* with terminating `NULL`. | Number of characters written. | N/A | No |
+| `format == NULL` | No data is written. If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value. | -1 | `EINVAL` (22) | Yes |
+
+For information about these and other error codes, see [`_doserrno`, `errno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
+
> [!IMPORTANT]
> Ensure that *`format`* is not a user-defined string. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
> [!NOTE]
-> To ensure that there is room for the terminating null, be sure that *`count`* is strictly less than the buffer length, or use `_TRUNCATE`.
+> To ensure that there is room for the terminating `NULL`, be sure that *`count`* is strictly less than the buffer length, or use `_TRUNCATE`.
In C++, using these functions is simplified by template overloads; the overloads can infer buffer length automatically (eliminating the need to specify a size argument) and they can automatically replace older, non-secure functions with their newer, secure counterparts. For more information, see [Secure template overloads](../secure-template-overloads.md).
@@ -196,4 +212,4 @@ nSize: -1, buff: Hi there!
[`fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`](fprintf-fprintf-l-fwprintf-fwprintf-l.md)\
[`printf`, `_printf_l`, `wprintf`, `_wprintf_l`](printf-printf-l-wprintf-wprintf-l.md)\
[`sprintf`, `_sprintf_l`, `swprintf`, `_swprintf_l`, `__swprintf_l`](sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md)\
-[`va_arg`, `va_copy`, `va_end`, `va_start`](va-arg-va-copy-va-end-va-start.md)\
+[`va_arg`, `va_copy`, `va_end`, `va_start`](va-arg-va-copy-va-end-va-start.md)
diff --git a/docs/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md b/docs/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md
index fde8ac1f41..1f94c8f59a 100644
--- a/docs/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md
+++ b/docs/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md
@@ -1,7 +1,7 @@
---
title: "vsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_l"
description: "API reference for vsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, and _vsnwprintf_l; which write formatted output using a pointer to a list of arguments."
-ms.date: "3/9/2021"
+ms.date: 06/27/2023
api_name: ["_vsnprintf", "_vsnprintf_l", "_vsnwprintf", "_vsnwprintf_l", "_vsnprintf", "_vsnprintf;", "vsnprintf; _vsnprintf", "_vsnwprintf;", "_vsnprintf_l;", "_vsnwprintf_l;"]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ntoskrnl.exe", "ucrtbase.dll"]
api_type: ["DLLExport"]
@@ -22,12 +22,14 @@ int vsnprintf(
const char *format,
va_list argptr
);
+
int _vsnprintf(
char *buffer,
size_t count,
const char *format,
va_list argptr
);
+
int _vsnprintf_l(
char *buffer,
size_t count,
@@ -35,12 +37,14 @@ int _vsnprintf_l(
_locale_t locale,
va_list argptr
);
+
int _vsnwprintf(
wchar_t *buffer,
size_t count,
const wchar_t *format,
va_list argptr
);
+
int _vsnwprintf_l(
wchar_t *buffer,
size_t count,
@@ -48,6 +52,7 @@ int _vsnwprintf_l(
_locale_t locale,
va_list argptr
);
+
template
int vsnprintf(
char (&buffer)[size],
@@ -55,6 +60,7 @@ int vsnprintf(
const char *format,
va_list argptr
); // C++ only
+
template
int _vsnprintf(
char (&buffer)[size],
@@ -62,6 +68,7 @@ int _vsnprintf(
const char *format,
va_list argptr
); // C++ only
+
template
int _vsnprintf_l(
char (&buffer)[size],
@@ -70,6 +77,7 @@ int _vsnprintf_l(
_locale_t locale,
va_list argptr
); // C++ only
+
template
int _vsnwprintf(
wchar_t (&buffer)[size],
@@ -77,6 +85,7 @@ int _vsnwprintf(
const wchar_t *format,
va_list argptr
); // C++ only
+
template
int _vsnwprintf_l(
wchar_t (&buffer)[size],
@@ -93,7 +102,7 @@ int _vsnwprintf_l(
Storage location for output.
*`count`*\
-Maximum number of characters to write.
+Maximum number of characters to write. For the functions that take `wchar_t`, it's the number of wide characters to write.
*`format`*\
Format specification.
@@ -108,19 +117,15 @@ For more information, see [Format specification syntax](../format-specification-
## Return value
-The **`vsnprintf`** function returns the number of characters that are written, not counting the terminating null character. If the buffer size specified by *`count`* isn't sufficiently large to contain the output specified by *`format`* and *`argptr`*, the return value of **`vsnprintf`** is the number of characters that would be written, not counting the null character, if *`count`* were sufficiently large. If the return value is greater than *`count`* - 1, the output has been truncated. A return value of -1 indicates that an encoding error has occurred.
-
-Both **`_vsnprintf`** and **`_vsnwprintf`** functions return the number of characters written if the number of characters to write is less than or equal to *`count`*. If the number of characters to write is greater than *`count`*, these functions return -1 indicating that output has been truncated.
-
-The value returned by all these functions doesn't include the terminating null, whether one is written or not.
+The number of characters written, not including the terminating `NULL`, or a negative value if an output error occurs.
-- If *`count`* is zero and *`buffer`* is `NULL`, the value returned is the number of characters the functions would write. The value doesn't take into account a terminating `NULL`. You can use this result to allocate sufficient buffer space for the string and a terminating null, and then call the function again to fill the buffer.
-- If *`count`* is zero but *`buffer`* isn't `NULL`, nothing is written and the function returns `-1`.
-- If *`format`* is `NULL`, or if *`buffer`* is `NULL` and *`count`* isn't equal to zero, these functions invoke the invalid parameter handler, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, these functions return -1 and set `errno` to `EINVAL`.
+See [Behavior summary](#behavior-summary) for details.
## Remarks
-Each of these functions takes a pointer to an argument list, then formats the data, and writes up to *`count`* characters to the memory pointed to by *`buffer`*. The **`vsnprintf`** function always writes a null terminator, even if it truncates the output. When you use **`_vsnprintf`** and **`_vsnwprintf`**, the buffer is null-terminated only if there's room at the end (that is, if the number of characters to write is less than *`count`*).
+Each of these functions takes a pointer to an argument list, then formats the data, and writes up to *`count`* characters to the memory pointed to by *`buffer`*. The **`vsnprintf`** function always writes a null terminator, even if it truncates the output. When you use **`_vsnprintf`** and **`_vsnwprintf`**, the buffer is null-terminated only if there's room at the end (that is, if the number of characters to write is less than *`count`*).
+
+Beginning with the UCRT in Visual Studio 2015 and Windows 10, **`vsnprintf`** is no longer identical to **`_vsnprintf`**. The **`vsnprintf`** function conforms to the C99 standard; **`_vsnprintf`** is kept for backward compatibility with older code. The difference is that if you run out of buffer, `vsnprintf` null-terminates the end of the buffer and returns the number of characters that would have been required, while `_vsnprintf` doesn't null-terminate the buffer and returns -1. Also, `_vsnprintf()` includes one more character in the output because it doesn't null-terminate the buffer.
> [!IMPORTANT]
> To prevent certain kinds of security risks, ensure that *`format`* isn't a user-defined string. For more information, see [Avoiding buffer overruns](/windows/win32/SecBP/avoiding-buffer-overruns).
@@ -129,14 +134,38 @@ Each of these functions takes a pointer to an argument list, then formats the da
> [!NOTE]
> To ensure that there's room for the terminating null when calling **`_vsnprintf`**, **`_vsnprintf_l`**, **`_vsnwprintf`** and **`_vsnwprintf_l`**, be sure that *`count`* is strictly less than the buffer length and initialize the buffer to null prior to calling the function.
>
-> Because **`vsnprintf`** always writes the terminating null, the *`count`* parameter may be equal to the size of the buffer.
-
-Beginning with the UCRT in Visual Studio 2015 and Windows 10, **`vsnprintf`** is no longer identical to **`_vsnprintf`**. The **`vsnprintf`** function conforms to the C99 standard; **`_vnsprintf`** is kept for backward compatibility with older Visual Studio code.
+> Because **`vsnprintf`** always writes a terminating null, the *`count`* parameter may be equal to the size of the buffer.
The versions of these functions with the **`_l`** suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see [Secure template overloads](../secure-template-overloads.md).
+### Behavior summary
+
+For the following table:
+
+- Let `sizeOfBuffer` be the size of `buffer`. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+- Let `len` be the size of the formatted data. If the function takes a `char` buffer, the size is in bytes. If the function takes a `wchar_t` buffer, the size specifies the number of 16-bit words.
+- Characters refer to `char` characters for functions that take a `char` buffer, and to `wchar_t` characters for functions that take a `wchar_t` buffer.
+- For more information about the invalid parameter handler, see [Parameter Validation](../../c-runtime-library/parameter-validation.md).
+
+| Condition | Behavior | Return value | `errno` | Invokes invalid parameter handler|
+|--|--|--|--|--|
+| Success | Writes the characters into the buffer using the specified format string. | The number of characters written, not counting the terminating null character. | N/A | No |
+| Encoding error during formatting | If processing string specifier `s`, `S`, or `Z`, format specification processing stops. | -1 | `EILSEQ` (42) | No |
+| Encoding error during formatting | If processing character specifier `c` or `C`, the invalid character is skipped. The number of characters written isn't incremented for the skipped character, nor is any data written for it. Processing the format specification continues after skipping the specifier with the encoding error. | The number of characters written, not including the terminating `NULL`. | `EILSEQ` (42) | No |
+| `buffer == NULL` and `count != 0` | If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value.| -1 | `EINVAL` (22) | Yes |
+| `buffer == NULL` and `count == 0` | No data is written | The number of characters that would have been written, not including the terminating `NULL`. You can use this result to allocate sufficient buffer space for the string and a terminating `NULL`, and then call the function again to fill the buffer. | N/A | No |
+| `count == 0` | No data is written | -1 | `ERANGE` (34) | No |
+| `count < 0`| Unsafe: the value is treated as unsigned, likely creating a large value that results in overwriting the memory that follows the buffer. | The number of characters written. | N/A | No |
+| `count < sizeOfBuffer` and `len <= count` | All of the data is written and a terminating `NULL` is appended. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `count < sizeOfBuffer` and `len > count` | The first *`count-1`* characters are written followed by a null-terminator. | The number of characters that would have been written had `count` matched the number of characters to output, not including the null-terminator. | N/A | No |
+| `count >= sizeOfBuffer` and `len < sizeOfBuffer` | All of the data is written with a terminating `NULL`. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `count >= sizeOfBuffer` and `len >= sizeOfBuffer` | Unsafe: overwrites the memory that follows the buffer. | The number of characters written, not including the terminating `NULL`. | N/A | No |
+| `format == NULL` | No data is written. If execution continues after invalid parameter handler executes, sets `errno` and returns a negative value. | -1 | `EINVAL` (22) | Yes |
+
+For information about these and other error codes, see [`_doserrno`, `errno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
+
### Generic-text routine mappings
| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
diff --git a/docs/c-runtime-library/reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l.md b/docs/c-runtime-library/reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l.md
index a5ab73d417..75116027f6 100644
--- a/docs/c-runtime-library/reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l.md
+++ b/docs/c-runtime-library/reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l.md
@@ -66,7 +66,9 @@ The locale to use.
## Return value
-**`_vsprintf_p`** and **`_vswprintf_p`** return the number of characters written, not including the terminating null character, or a negative value if an output error occurs.
+**`_vsprintf_p`** and **`_vswprintf_p`** return the number of characters written, not including the terminating `NULL` character, or a negative value if an output error occurs.
+If the *`buffer`* is a `NULL` pointer and *`sizeInBytes`* or *`count`* are zero, functions return the number of characters that would have been written not including the terminating `NULL`.
+If the *`buffer`* is valid and *`sizeInBytes`* or *`count`* are zero, returns -1.
## Remarks
@@ -76,7 +78,7 @@ These functions differ from the `vsprintf_s` and `vswprintf_s` only in that they
The versions of these functions with the `_l` suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
-If the *`buffer`* or *`format`* parameters are `NULL` pointers, if count is zero, or if the format string contains invalid formatting characters, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, the functions return -1 and set `errno` to `EINVAL`.
+If the *`buffer`* or *`format`* parameters are `NULL` pointers, or if the format string contains invalid formatting characters, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, the functions return -1 and set `errno` to `EINVAL`.
> [!IMPORTANT]
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
diff --git a/docs/c-runtime-library/reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md b/docs/c-runtime-library/reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md
index 184d230286..991b132063 100644
--- a/docs/c-runtime-library/reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md
+++ b/docs/c-runtime-library/reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md
@@ -1,18 +1,20 @@
---
description: "Learn more about: vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l"
-title: "vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l"
+title: "vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l, _vstprintf_s, _vstprintf_s_l"
ms.date: "3/9/2021"
-api_name: ["_vswprintf_s_l", "vsprintf_s", "vswprintf_s", "_vsprintf_s_l"]
+api_name: ["_vswprintf_s_l", "vsprintf_s", "vswprintf_s", "_vsprintf_s_l", _vstprintf_s, _vstprintf_s_l]
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "ntoskrnl.exe"]
api_type: ["DLLExport"]
topic_type: ["apiref"]
-f1_keywords: ["CORECRT_WSTDIO/vswprintf_s", "STDIO/vsprintf_s", "TCHAR/_vstprintf_s", "vswprintf_s", "vsprintf_s", "_vstprintf_s"]
+f1_keywords: ["CORECRT_WSTDIO/vswprintf_s", "STDIO/vsprintf_s", "TCHAR/_vstprintf_s", "vswprintf_s", "vsprintf_s", "_vstprintf_s", "_vstprintf_s_l", "_vswprintf_s_l"]
helpviewer_keywords: ["_vstprintf_s_l function", "vsprintf_s_l function", "_vstprintf_s function", "vswprintf_s function", "vstprintf_s function", "vstprintf_s_l function", "vswprintf_s_l function", "vsprintf_s function", "_vsprintf_s_l function", "formatted text [C++]", "_vswprintf_s_l function"]
---
-# `vsprintf_s`, `_vsprintf_s_l`, `vswprintf_s`, `_vswprintf_s_l`
+# `vsprintf_s`, `_vsprintf_s_l`, `vswprintf_s`, `_vswprintf_s_l`, `_vstprintf_s`, `_vstprintf_s_l`
Write formatted output using a pointer to a list of arguments. These functions are versions of [`vsprintf`, `_vsprintf_l`, `vswprintf`, `_vswprintf_l`, \`__vswprintf_l`](vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md) with security enhancements as described in [Security features in the CRT](../security-features-in-the-crt.md).
+For `_vstprintf_s` and `_vstprintf_s_l`, see [Generic-text function mappings](#generic-text-function-mappings).
+
## Syntax
```C
@@ -94,12 +96,14 @@ In C++, using these functions is simplified by template overloads. The overloads
> [!IMPORTANT]
> Starting in Windows 10 version 2004 (build 19041), the `printf` family of functions prints exactly representable floating point numbers according to the IEEE 754 rules for rounding. In previous versions of Windows, exactly representable floating point numbers ending in '5' would always round up. IEEE 754 states that they must round to the closest even digit (also known as "Banker's Rounding"). For example, both `printf("%1.0f", 1.5)` and `printf("%1.0f", 2.5)` should round to 2. Previously, 1.5 would round to 2 and 2.5 would round to 3. This change only affects exactly representable numbers. For example, 2.35 (which, when represented in memory, is closer to 2.35000000000000008) continues to round up to 2.4. Rounding done by these functions now also respects the floating point rounding mode set by [`fesetround`](fegetround-fesetround2.md). Previously, rounding always chose `FE_TONEAREST` behavior. This change only affects programs built using Visual Studio 2019 version 16.2 and later. To use the legacy floating point rounding behavior, link with ['legacy_stdio_float_rounding.obj`](../link-options.md).
-### Generic-text routine mappings
+### Generic-text function mappings
+
+The function in the `tchar.h` column maps to the function in the other columns depending on the character set that is defined at compile time.
-| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
+| `tchar.h` function | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
-| `_vstprintf_s` | **`vsprintf_s`** | **`vsprintf_s`** | **`vswprintf_s`** |
-| `_vstprintf_s_l` | **`_vsprintf_s_l`** | **`_vsprintf_s_l`** | **`_vswprintf_s_l`** |
+| `_vstprintf_s` | `vsprintf_s` | `vsprintf_s` | `vswprintf_s` |
+| `_vstprintf_s_l` | `_vsprintf_s_l` | `_vsprintf_s_l` | `_vswprintf_s_l` |
## Requirements
diff --git a/docs/c-runtime-library/reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md b/docs/c-runtime-library/reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md
index 0d197f9619..b3296103ad 100644
--- a/docs/c-runtime-library/reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md
+++ b/docs/c-runtime-library/reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md
@@ -95,6 +95,10 @@ The locale to use.
**`vsprintf`** and **`vswprintf`** return the number of characters written, not including the terminating `NULL` character, or a negative value if an output error occurs. If *`buffer`* or *`format`* is a `NULL` pointer, these functions invoke the invalid parameter handler, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, these functions return -1 and set `errno` to `EINVAL`.
+If *`buffer`* is a `NULL` pointer and *`count`* is zero, **`vswprintf`** and **`_vswprintf_l`** return the number of characters that would have been written not including the terminating NULL.
+
+If *`buffer`* is valid and *`count`* is zero, **`vswprintf`** and **`_vswprintf_l`** return -1. The contents of *`buffer`* are unchanged.
+
For information on these and other error codes, see [`errno`, `_doserrno`, `_sys_errlist`, and `_sys_nerr`](../errno-doserrno-sys-errlist-and-sys-nerr.md).
## Remarks
diff --git a/docs/c-runtime-library/routine-mappings.md b/docs/c-runtime-library/routine-mappings.md
index 64d52861ae..087515c0cd 100644
--- a/docs/c-runtime-library/routine-mappings.md
+++ b/docs/c-runtime-library/routine-mappings.md
@@ -1,19 +1,21 @@
---
-description: "Learn more about: Routine Mappings"
-title: "Routine Mappings"
+description: "Learn more about: Microsoft specific generic-text functions and the CRT functions they map to."
+title: "Generic-text function mappings"
ms.date: "11/04/2016"
-helpviewer_keywords: ["_tWinMain", "TCHAR.H data types, list of routine mappings", "generic-text mappings"]
-ms.assetid: 38f33d3b-0f7b-430d-8a4f-75e27c6f1c42
+ms.author: twhitney
+api_name: ["foo",]
+f1_keywords: ["_cgetts", "_cgetts_s", "_cputts", "_fgettc", "_fgettchar", "_fgetts", "_fputtc", "_fputtchar", "_fputts", "_ftscanf", "_ftscanf_s", "_gettc", "_gettch", "_gettchar", "_gettche", "_getts", "_getts_s", "_istalnum", "_istalpha", "_istascii", "_istcntrl", "_istdigit", "_istgraph", "_istlead", "_istleadbyte", "_istlegal", "_istlower", "_istprint", "_istpunct", "_istspace", "_istupper", "_istxdigit", "_itot", "_itot_s", "_ltot", "_ltot_s", "_puttc", "_puttch", "_puttchar", "_putts", "_sctprintf", "_sntprintf", "_sntprintf_s", "_sntscanf", "_sntscanf_s", "_stprintf", "_stprintf_s", "_stscanf", "_stscanf_s", "_taccess", "_tasctime", "_tasctime_s", "_tccmp", "_tccpy", "_tccpy_s", "_tchdir", "_tclen", "_tchmod", "_tcprintf", "_tcprintf_s", "_tcreat", "_tcscanf", "_tcscanf_s", "_tcscat", "_tcscat_s", "_tcschr", "_tcsclen", "_tcsclen_s", "_tcscmp", "_tcscoll", "_tcscpy", "_tcscpy_s", "_tcscspn", "_tcsdec", "_tcsdup", "_tcserror", "_tcserror_s", "_tcsftime", "_tcsicmp", "_tcsicoll", "_tcsinc", "_tcslen", "_tcslwr", "_tcslwr_s", "_tcsnbcnt", "_tcsncat", "_tcsncat_s", "_tcsnccat", "_tcsnccmp", "_tcsnccmp_s", "_tcsnccoll", "_tcsncmp", "_tcsnccnt", "_tcsnccpy", "_tcsncicmp", "_tcsncicoll", "_tcsncpy", "_tcsncset", "_tcsnextc", "_tcsnicmp", "_tcsnicoll", "_tcsninc", "_tcsnccnt", "_tcsnset", "_tcspbrk", "_tcsspnp", "_tcsrchr", "_tcsrev", "_tcsset", "_tcsspn", "_tcsstr", "_tcstod", "_tcstoi64", "_tcstok", "_tcstok_s", "_tcstol", "_tcstoui64", "_tcstoul", "_tcsupr", "_tcsupr_s", "_tcsxfrm", "_tctime", "_tctime_s", "_tctime32", "_tctime32_s", "_tctime64", "_tctime64_s", "_texecl", "_texecle", "_texeclp", "_texeclpe", "_texecv", "_texecve", "_texecvp", "_texecvpe", "_tfdopen", "_tfindfirst", "_tfindnext", "_tfindnext32", "_tfindnext64", "_tfindnexti64", "_tfindnexti6432", "_tfindnext32i64", "_tfopen", "_tfopen_s", "_tfreopen", "_tfreopen_s", "_tfsopen", "_tfullpath", "_tgetcwd", "_tgetdcwd", "_tgetenv", "_tgetenv_s", "_tmain", "_tmakepath", "_tmakepath_s", "_tmkdir", "_tmktemp", "_tmktemp_s", "_topen", "_topen_s", "_totlower", "_totupper", "_tperror", "_tpopen", "_tprintf", "_tprintf_s", "_tputenv", "_tremove", "_trename", "_trmdir", "_tsearchenv", "_tsearchenv_s", "_tscanf", "_tscanf_s", "_tsetlocale", "_tsopen", "_tsopen_s", "_tspawnl", "_tspawnle", "_tspawnlp", "_tspawnlpe", "_tspawnv", "_tspawnve", "_tspawnvp", "_tspawnvpe", "_tsplitpath", "_tstat", "_tstat32", "_tstati32", "_tstat64", "_tstati64", "_tstof", "_tstoi", "_tstoi64", "_tstol", "_tstrdate", "_tstrdate_s", "_tstrtime", "_tstrtime_s", "_tsystem", "_ttempnam", "_ttmpnam", "_ttmpnam_s", "_ttoi", "_ttoi64", "_ttol", "_tunlink", "_tutime", "_tutime32", "_tutime64", "_tWinMain", "_ui64tot", "_ui64tot_s", "_ultot", "_ultot_s", "_ungettc", "_ungettch", "_vftprintf", "_vftprintf_s", "_vsctprintf", "_vsctprintf_s", "_vsntprintf", "_vsntprintf_s", "_vstprintf", "_vtprintf", "_vtprintf_s"]
+helpviewer_keywords: ["_tWinMain", "TCHAR.H functions, list of generic-text function mappings", "generic-text mappings", "_cgetts function", "_cgetts_s function", "_cputts function", "_fgettc function", "_fgettchar function", "_fgetts function", "_fputtc function", "_fputtchar function", "_fputts function", "_ftscanf function", "_ftscanf_s function", "_gettc function", "_gettch function", "_gettchar function", "_gettche function", "_getts function", "_getts_s function", "_istalnum function", "_istalpha function", "_istascii function", "_istcntrl function", "_istdigit function", "_istgraph function", "_istlead function", "_istleadbyte function", "_istlegal function", "_istlower function", "_istprint function", "_istpunct function", "_istspace function", "_istupper function", "_istxdigit function", "_itot function", "_itot_s function", "_ltot function", "_ltot_s function", "_puttc function", "_puttch function", "_puttchar function", "_putts function", "_sctprintf function", "_sntprintf function", "_sntprintf_s function", "_sntscanf function", "_sntscanf_s function", "_stprintf function", "_stprintf_s function", "_stscanf function", "_stscanf_s function", "_taccess function", "_tasctime function", "_tasctime_s function", "_tccmp function", "_tccpy function", "_tccpy_s function", "_tchdir function", "_tclen function", "_tchmod function", "_tcprintf function", "_tcprintf_s function", "_tcreat function", "_tcscanf function", "_tcscanf_s function", "_tcscat function", "_tcscat_s function", "_tcschr function", "_tcsclen function", "_tcsclen_s function", "_tcscmp function", "_tcscoll function", "_tcscpy function", "_tcscpy_s function", "_tcscspn function", "_tcsdec function", "_tcsdup function", "_tcserror function", "_tcserror_s function", "_tcsftime function", "_tcsicmp function", "_tcsicoll function", "_tcsinc function", "_tcslen function", "_tcslwr function", "_tcslwr_s function", "_tcsnbcnt function", "_tcsncat function", "_tcsncat_s function", "_tcsnccat function", "_tcsnccmp function", "_tcsnccmp_s function", "_tcsnccoll function", "_tcsncmp function", "_tcsnccnt function", "_tcsnccpy function", "_tcsncicmp function", "_tcsncicoll function", "_tcsncpy function", "_tcsncset function", "_tcsnextc function", "_tcsnicmp function", "_tcsnicoll function", "_tcsninc function", "_tcsnccnt function", "_tcsnset function", "_tcspbrk function", "_tcsspnp function", "_tcsrchr function", "_tcsrev function", "_tcsset function", "_tcsspn function", "_tcsstr function", "_tcstod function", "_tcstoi64 function", "_tcstok function", "_tcstok_s function", "_tcstol function", "_tcstoui64 function", "_tcstoul function", "_tcsupr function", "_tcsupr_s function", "_tcsxfrm function", "_tctime function", "_tctime_s function", "_tctime32 function", "_tctime32_s function", "_tctime64 function", "_tctime64_s function", "_texecl function", "_texecle function", "_texeclp function", "_texeclpe function", "_texecv function", "_texecve function", "_texecvp function", "_texecvpe function", "_tfdopen function", "_tfindfirst function", "_tfindnext function", "_tfindnext32 function", "_tfindnext64 function", "_tfindnexti64 function", "_tfindnexti6432 function", "_tfindnext32i64 function", "_tfopen function", "_tfopen_s function", "_tfreopen function", "_tfreopen_s function", "_tfsopen function", "_tfullpath function", "_tgetcwd function", "_tgetdcwd function", "_tgetenv function", "_tgetenv_s function", "_tmain function", "_tmakepath function", "_tmakepath_s function", "_tmkdir function", "_tmktemp function", "_tmktemp_s function", "_topen function", "_topen_s function", "_totlower function", "_totupper function", "_tperror function", "_tpopen function", "_tprintf function", "_tprintf_s function", "_tputenv function", "_tremove function", "_trename function", "_trmdir function", "_tsearchenv function", "_tsearchenv_s function", "_tscanf function", "_tscanf_s function", "_tsetlocale function", "_tsopen function", "_tsopen_s function", "_tspawnl function", "_tspawnle function", "_tspawnlp function", "_tspawnlpe function", "_tspawnv function", "_tspawnve function", "_tspawnvp function", "_tspawnvpe function", "_tsplitpath function", "_tstat function", "_tstat32 function", "_tstati32 function", "_tstat64 function", "_tstati64 function", "_tstof function", "_tstoi function", "_tstoi64 function", "_tstol function", "_tstrdate function", "_tstrdate_s function", "_tstrtime function", "_tstrtime_s function", "_tsystem function", "_ttempnam function", "_ttmpnam function", "_ttmpnam_s function", "_ttoi function", "_ttoi64 function", "_ttol function", "_tunlink function", "_tutime function", "_tutime32 function", "_tutime64 function", "_tWinMain function", "_ui64tot function", "_ui64tot_s function", "_ultot function", "_ultot_s function", "_ungettc function", "_ungettch function", "_vftprintf function", "_vftprintf_s function", "_vsctprintf function", "_vsctprintf_s function", "_vsntprintf function", "_vsntprintf_s function", "_vstprintf function", "_vtprintf function", "_vtprintf_s function"]
---
-# Routine mappings
+# Generic-text function mappings
-The generic-text routine mappings are defined in TCHAR.H. `_tccpy` and `_tclen` map to functions in the MBCS model; they're mapped to macros or inline functions in the SBCS and Unicode models for completeness. For information on a generic text routine, see the help article about the corresponding `SBCS`-, `_MBCS`-, or `_UNICODE`-related routine.
+The generic-text routine mappings are defined in `TCHAR.H`. `_tccpy` and `_tclen` map to functions in the MBCS model; they're mapped to macros or inline functions in the SBCS and Unicode models for completeness. For information on a generic text routine, see the help article about the corresponding `SBCS`-, `_MBCS`-, or `_UNICODE`-related routine.
More specific information about individual routines listed in the left column in the following table isn't available in this documentation. However, you can easily look up the information on a corresponding `SBCS`-, `_MBCS`-, or `_UNICODE`-related routine. Use the **Search** command on the **Help** menu to look up any generic-text routine listed below.
For related information, see [Generic-text mappings in tchar.h](../text/generic-text-mappings-in-tchar-h.md).
-### Generic-text routine mappings
+### Function mappings
| Generic-text routine name | `SBCS` (`_UNICODE` and `MBCS` not defined) | `_MBCS` defined | `_UNICODE` defined |
|---|---|---|---|
@@ -27,6 +29,7 @@ For related information, see [Generic-text mappings in tchar.h](../text/generic-
| `_fputtchar` | `_fputchar` | `_fputchar` | `_fputwchar` |
| `_fputts` | `fputs` | `fputs` | `fputws` |
| `_ftprintf` | `fprintf` | `fprintf` | `fwprintf` |
+| `_ftprintf_l` | `_fprintf_l` | `_fprintf_l` | `_fwprintf_l` |
| `_ftprintf_s` | `fprintf_s` | `fprintf_s` | `fwprintf_s` |
| `_ftscanf` | `fscanf` | `fscanf` | `fwscanf` |
| `_ftscanf_s` | `fscanf_s` | `fscanf_s` | `fwscanf_s` |
diff --git a/docs/c-runtime-library/rtdynamiccast.md b/docs/c-runtime-library/rtdynamiccast.md
index c94de1779c..791143e7c0 100644
--- a/docs/c-runtime-library/rtdynamiccast.md
+++ b/docs/c-runtime-library/rtdynamiccast.md
@@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["RTTIDATA/__RTDynamicCast", "__RTDynamicCast"]
helpviewer_keywords: ["__RTDynamicCast"]
-ms.assetid: 56aa2d7a-aa47-46ef-830d-e37175611239
---
# `__RTDynamicCast`
@@ -17,13 +16,13 @@ Runtime implementation of the [`dynamic_cast`](../cpp/dynamic-cast-operator.md)
## Syntax
```cpp
-PVOID __RTDynamicCast (
+PVOID __RTDynamicCast(
PVOID inptr,
LONG VfDelta,
PVOID SrcType,
PVOID TargetType,
BOOL isReference
- ) throw(...)
+) throw(...)
```
#### Parameters
@@ -45,7 +44,7 @@ Intended result of cast.
## Return value
-Pointer to the appropriate subobject, if successful; otherwise, `NULL`.
+Pointer to the appropriate subobject if successful; otherwise, `NULL`.
## Exceptions
@@ -59,4 +58,4 @@ Converts `inptr` to an object of type `TargetType`. The type of `inptr` must be
| Routine | Required header |
|---|---|
-| **`__RTDynamicCast`** | `` |
+| **`__RTDynamicCast`** | `` |
diff --git a/docs/c-runtime-library/security-features-in-the-crt.md b/docs/c-runtime-library/security-features-in-the-crt.md
index d1dc77a81a..06117a37fd 100644
--- a/docs/c-runtime-library/security-features-in-the-crt.md
+++ b/docs/c-runtime-library/security-features-in-the-crt.md
@@ -5,7 +5,6 @@ ms.date: "09/29/2020"
ms.topic: "conceptual"
f1_keywords: ["_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_DEPRECATE", "_CRT_NONSTDC_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"]
helpviewer_keywords: ["security deprecation warnings [C++]", "CRT_NONSTDC_NO_DEPRECATE", "buffers [C++], buffer overruns", "deprecation warnings (security-related), disabling", "_CRT_NONSTDC_NO_WARNINGS", "security [CRT]", "_CRT_SECURE_NO_WARNINGS", "_CRT_NONSTDC_NO_DEPRECATE", "_CRT_SECURE_NO_DEPRECATE", "security-enhanced CRT", "CRT_SECURE_NO_WARNINGS", "CRT_SECURE_NO_DEPRECATE", "deprecation warnings (security-related)", "buffer overruns", "CRT_NONSTDC_NO_WARNINGS", "CRT, security enhancements", "parameters [C++], validation"]
-ms.assetid: d9568b08-9514-49cd-b3dc-2454ded195a3
---
# Security Features in the CRT
@@ -19,7 +18,7 @@ For example, the `strcpy` function can't tell if the string it copies is too lar
## Eliminating deprecation warnings
-There are several ways to eliminate deprecation warnings for the older, less secure functions. The simplest is simply to define `_CRT_SECURE_NO_WARNINGS` or use the [`warning`](../preprocessor/warning.md) pragma. Either will disable deprecation warnings, but the security issues that caused the warnings still exist. It's better to leave deprecation warnings enabled and take advantage of the new CRT security features.
+There are several ways to eliminate deprecation warnings for the older, less secure functions. The simplest is simply to define `_CRT_SECURE_NO_WARNINGS` or use the [`warning`](../preprocessor/warning.md) pragma. Either disables deprecation warnings, but the security issues that caused the warnings still exist. It's better to leave deprecation warnings enabled and take advantage of the new CRT security features.
In C++, the easiest way to eliminate the deprecation warnings is to use [Secure template overloads](./secure-template-overloads.md). The overloads eliminate deprecation warnings in many cases. They replace calls to deprecated functions with calls to secure versions of the functions. For example, consider this deprecated call to `strcpy`:
@@ -54,13 +53,15 @@ Some of the security features include:
You must pass the buffer size to any secure function that writes to a buffer. The secure versions validate that the buffer is large enough before writing to it. The validation helps avoid dangerous buffer overrun errors that could allow malicious code to execute. These functions usually return an `errno` error code and invoke the invalid parameter handler if the size of the buffer is too small. Functions that read from input buffers, such as `gets`, have secure versions that require you to specify a maximum size.
+ The debug versions of *some* security-enhanced CRT functions fill the buffer passed to them with a special character (0xFE). This fill character helps to find cases where the incorrect size was passed to the function. Unfortunately, it also reduces performance. To improve performance, use **`_CrtSetDebugFillThreshold`** to disable buffer-filling. For more information, and a list of functions that have this behavior, see [`_CrtSetDebugFillThreshold`](./reference/crtsetdebugfillthreshold.md).
+
- **Null termination**
- Some functions that left potentially non-terminated strings have secure versions, which ensure that strings are properly null-terminated.
+ Some functions that left potentially nonterminated strings have secure versions, which ensure that strings are properly null-terminated.
- **Enhanced error reporting**
- The secure functions return error codes with more error information than was available with the pre-existing functions. The secure functions and many of the pre-existing functions now set `errno` and often return an `errno` code type as well, to provide better error reporting.
+ The secure functions return error codes with more error information than was available with the preexisting functions. The secure functions and many of the preexisting functions now set `errno` and often return an `errno` code type as well, to provide better error reporting.
- **Filesystem security**
diff --git a/docs/c-runtime-library/stdin-stdout-stderr.md b/docs/c-runtime-library/stdin-stdout-stderr.md
index 466b85a7fb..b88b099b36 100644
--- a/docs/c-runtime-library/stdin-stdout-stderr.md
+++ b/docs/c-runtime-library/stdin-stdout-stderr.md
@@ -1,20 +1,18 @@
---
-description: "Learn more about: stdin, stdout, stderr"
+description: "Learn more about the definitions of: stdin, stdout, stderr"
title: "stdin, stdout, stderr"
-ms.date: "10/23/2018"
+ms.date: "7/24/2023"
f1_keywords: ["CORECRT_WSTDIO/stdin", "CORECRT_WSTDIO/stderr", "CORECRT_WSTDIO/stdout", "stdin", "stderr", "stdout"]
helpviewer_keywords: ["stdout function", "standard output stream", "standard error stream", "stdin function", "standard input stream", "stderr function"]
-ms.assetid: badd4735-596d-4498-857c-ec8b7e670e4c
---
# `stdin`, `stdout`, `stderr`
## Syntax
```C
-FILE *stdin;
-FILE *stdout;
-FILE *stderr;
-#include
+#define stdin /* implementation defined */
+#define stdout /* implementation defined */
+#define stderr /* implementation defined */
```
## Remarks
diff --git a/docs/c-runtime-library/stream-i-o.md b/docs/c-runtime-library/stream-i-o.md
index 180ecf2b1f..e91fcfdda2 100644
--- a/docs/c-runtime-library/stream-i-o.md
+++ b/docs/c-runtime-library/stream-i-o.md
@@ -1,9 +1,8 @@
---
-description: "Learn more about: Stream I/O"
title: "Stream I/O"
-ms.date: "11/04/2016"
+description: "Learn more about: Stream I/O"
+ms.date: 11/04/2016
helpviewer_keywords: ["I/O routines, stream I/O", "I/O [CRT], stream", "stream I/O"]
-ms.assetid: dc7874d3-a91b-456a-9015-4748bb358217
---
# Stream I/O
@@ -13,61 +12,61 @@ These functions process data in different sizes and formats, from single charact
| Routine | Use |
|---|---|
-| [`clearerr`](./reference/clearerr.md), [`clearerr_s`](./reference/clearerr-s.md) | Clear error indicator for stream |
-| [`fclose`](./reference/fclose-fcloseall.md) | Close stream |
-| [`_fcloseall`](./reference/fclose-fcloseall.md) | Close all open streams except **`stdin`**, **`stdout`**, and **`stderr`** |
-| [`_fdopen`, `wfdopen`](./reference/fdopen-wfdopen.md) | Associate stream with file descriptor of open file |
-| [`feof`](./reference/feof.md) | Test for end of file on stream |
-| [`ferror`](./reference/ferror.md) | Test for error on stream |
-| [`fflush`](./reference/fflush.md) | Flush stream to buffer or storage device |
-| [`fgetc`, `fgetwc`](./reference/fgetc-fgetwc.md) | Read character from stream (function versions of **`getc`** and **`getwc`**) |
-| [`_fgetchar`, `_fgetwchar`](./reference/fgetc-fgetwc.md) | Read character from **`stdin`** (function versions of **`getchar`** and **`getwchar`**) |
-| [`fgetpos`](./reference/fgetpos.md) | Get position indicator of stream |
-| [`fgets`, `fgetws`](./reference/fgets-fgetws.md) | Read string from stream |
-| [`_fileno`](./reference/fileno.md) | Get file descriptor associated with stream |
-| [`_flushall`](./reference/flushall.md) | Flush all streams to buffer or storage device |
-| [`fopen`, `_wfopen`](./reference/fopen-wfopen.md), [`fopen_s`, `_wfopen_s`](./reference/fopen-s-wfopen-s.md) | Open stream |
-| [`fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`](./reference/fprintf-fprintf-l-fwprintf-fwprintf-l.md), [`fprintf_s`, `_fprintf_s_l`, `fwprintf_s`, `_fwprintf_s_l`](./reference/fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md) | Write formatted data to stream |
-| [`fputc`, `fputwc`](./reference/fputc-fputwc.md) | Write a character to a stream (function versions of **`putc`** and **`putwc`**) |
-| [`_fputchar`, `_fputwchar`](./reference/fputc-fputwc.md) | Write character to **`stdout`** (function versions of **`putchar`** and **`putwchar`**) |
-| [`fputs`, `fputws`](./reference/fputs-fputws.md) | Write string to stream |
-| [`fread`](./reference/fread.md) | Read unformatted data from stream |
-| [`freopen`, `_wfreopen`](./reference/freopen-wfreopen.md), [`freopen_s`, `_wfreopen_s`](./reference/freopen-s-wfreopen-s.md) | Reassign `FILE` stream pointer to new file or device |
-| [`fscanf`, `fwscanf`](./reference/fscanf-fscanf-l-fwscanf-fwscanf-l.md), [`fscanf_s`, `_fscanf_s_l`, `fwscanf_s`, `_fwscanf_s_l`](./reference/fscanf-s-fscanf-s-l-fwscanf-s-fwscanf-s-l.md) | Read formatted data from stream |
-| [`fseek`, `_fseeki64`](./reference/fseek-fseeki64.md) | Move file position to given location |
-| [`fsetpos`](./reference/fsetpos.md) | Set position indicator of stream |
-| [`_fsopen`, `_wfsopen`](./reference/fsopen-wfsopen.md) | Open stream with file sharing |
-| [`ftell`, `_ftelli64`](./reference/ftell-ftelli64.md) | Get current file position |
-| [`fwrite`](./reference/fwrite.md) | Write unformatted data items to stream |
-| [`getc`, `getwc`](./reference/getc-getwc.md) | Read character from stream (macro versions of **`fgetc`** and **`fgetwc`**) |
-| [`getchar`, `getwchar`](./reference/getc-getwc.md) | Read character from **`stdin`** (macro versions of **`fgetchar`** and **`fgetwchar`**) |
-| [`_getmaxstdio`](./reference/getmaxstdio.md) | Returns the number of simultaneously open files permitted at the stream I/O level. |
-| [`gets_s`, `_getws_s`](./reference/gets-s-getws-s.md) | Read line from **`stdin`** |
-| [`_getw`](./reference/getw.md) | Read binary **`int`** from stream |
-| [`printf`, `_printf_l`, `wprintf`, `_wprintf_l`](./reference/printf-printf-l-wprintf-wprintf-l.md),[`printf_s`, `_printf_s_l`, `wprintf_s`, `_wprintf_s_l`](./reference/printf-s-printf-s-l-wprintf-s-wprintf-s-l.md) | Write formatted data to **`stdout`** |
-| [`putc`, `putwc`](./reference/putc-putwc.md) | Write character to a stream (macro versions of **`fputc`** and **`fputwc`**) |
-| [`putchar`, `putwchar`](./reference/putc-putwc.md) | Write character to **`stdout`** (macro versions of **`fputchar`** and **`fputwchar`**) |
-| [`puts`, `_putws`](./reference/puts-putws.md) | Write line to stream |
-| [`_putw`](./reference/putw.md) | Write binary **`int`** to stream |
-| [`rewind`](./reference/rewind.md) | Move file position to beginning of stream |
-| [`_rmtmp`](./reference/rmtmp.md) | Remove temporary files created by **`tmpfile`** |
-| [`scanf`, `_scanf_l`, `wscanf`, `_wscanf_l`](./reference/scanf-scanf-l-wscanf-wscanf-l.md),[`scanf_s`, `_scanf_s_l`, `wscanf_s`, `_wscanf_s_l`](./reference/scanf-s-scanf-s-l-wscanf-s-wscanf-s-l.md) | Read formatted data from **`stdin`** |
-| [`setbuf`](./reference/setbuf.md) | Control stream buffering |
-| [`_setmaxstdio`](./reference/setmaxstdio.md) | Set a maximum for the number of simultaneously open files at the stream I/O level. |
-| [`setvbuf`](./reference/setvbuf.md) | Control stream buffering and buffer size |
-| [`_snprintf`, `_snwprintf`](./reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md), [`_snprintf_s`, `_snprintf_s_l`, `_snwprintf_s`, `_snwprintf_s_l`](./reference/snprintf-s-snprintf-s-l-snwprintf-s-snwprintf-s-l.md) | Write formatted data of specified length to string |
-| [`_snscanf`, `_snwscanf`](./reference/snscanf-snscanf-l-snwscanf-snwscanf-l.md), [`_snscanf_s`, `_snscanf_s_l`, `_snwscanf_s`, `_snwscanf_s_l`](./reference/snscanf-s-snscanf-s-l-snwscanf-s-snwscanf-s-l.md) | Read formatted data of a specified length from the standard input stream. |
-| [`sprintf`, `swprintf`](./reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md), [`sprintf_s`, `_sprintf_s_l`, `swprintf_s`, `_swprintf_s_l`](./reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md) | Write formatted data to string |
-| [`sscanf`, `swscanf`](./reference/sscanf-sscanf-l-swscanf-swscanf-l.md), [`sscanf_s`, _sscanf_s_l, `swscanf_s`, `_swscanf_s_l`](./reference/sscanf-s-sscanf-s-l-swscanf-s-swscanf-s-l.md) | Read formatted data from string |
-| [`_tempnam`, `_wtempnam`](./reference/tempnam-wtempnam-tmpnam-wtmpnam.md) | Generate temporary filename in given directory |
-| [`tmpfile`](./reference/tmpfile.md), [`tmpfile_s`](./reference/tmpfile-s.md) | Create temporary file |
-| [`tmpnam`, `_wtmpnam`](./reference/tempnam-wtempnam-tmpnam-wtmpnam.md), [`tmpnam_s`, `_wtmpnam_s`](./reference/tmpnam-s-wtmpnam-s.md) | Generate temporary filename |
-| [`ungetc`, `ungetwc`](./reference/ungetc-ungetwc.md) | Push character back onto stream |
-| [`_vcprintf`, `_vcwprintf`](./reference/vcprintf-vcprintf-l-vcwprintf-vcwprintf-l.md), [`_vcprintf_s`, `_vcprintf_s_l`, `_vcwprintf_s`, `_vcwprintf_s_l`](./reference/vcprintf-s-vcprintf-s-l-vcwprintf-s-vcwprintf-s-l.md) | Write formatted data to the console. |
-| [`vfprintf`, `vfwprintf`](./reference/vfprintf-vfprintf-l-vfwprintf-vfwprintf-l.md), [`vfprintf_s`, `_vfprintf_s_l`, `vfwprintf_s`, `_vfwprintf_s_l`](./reference/vfprintf-s-vfprintf-s-l-vfwprintf-s-vfwprintf-s-l.md) | Write formatted data to stream |
-| [`vprintf`, `vwprintf`](./reference/vprintf-vprintf-l-vwprintf-vwprintf-l.md), [`vprintf_s`, `_vprintf_s_l`, `vwprintf_s`, `_vwprintf_s_l`](./reference/vprintf-s-vprintf-s-l-vwprintf-s-vwprintf-s-l.md) | Write formatted data to **`stdout`** |
-| [`_vsnprintf`, `_vsnwprintf`](./reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md), [`vsnprintf_s`, `_vsnprintf_s`, `_vsnprintf_s_l`, `_vsnwprintf_s`, `_vsnwprintf_s_l`](./reference/vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l.md) | Write formatted data of specified length to buffer |
-| [`vsprintf`, `vswprintf`](./reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md), [`vsprintf_s`, `_vsprintf_s_l`, `vswprintf_s`, `_vswprintf_s_l`](./reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md) | Write formatted data to buffer |
+| [`clearerr`](reference/clearerr.md), [`clearerr_s`](reference/clearerr-s.md) | Clear error indicator for stream |
+| [`fclose`](reference/fclose-fcloseall.md) | Close stream |
+| [`_fcloseall`](reference/fclose-fcloseall.md) | Close all open streams except **`stdin`**, **`stdout`**, and **`stderr`** |
+| [`_fdopen`, `wfdopen`](reference/fdopen-wfdopen.md) | Associate stream with file descriptor of open file |
+| [`feof`](reference/feof.md) | Test for end of file on stream |
+| [`ferror`](reference/ferror.md) | Test for error on stream |
+| [`fflush`](reference/fflush.md) | Flush stream to buffer or storage device |
+| [`fgetc`, `fgetwc`](reference/fgetc-fgetwc.md) | Read character from stream (function versions of **`getc`** and **`getwc`**) |
+| [`_fgetchar`, `_fgetwchar`](reference/fgetc-fgetwc.md) | Read character from **`stdin`** (function versions of **`getchar`** and **`getwchar`**) |
+| [`fgetpos`](reference/fgetpos.md) | Get position indicator of stream |
+| [`fgets`, `fgetws`](reference/fgets-fgetws.md) | Read string from stream |
+| [`_fileno`](reference/fileno.md) | Get file descriptor associated with stream |
+| [`_flushall`](reference/flushall.md) | Flush all streams to buffer or storage device |
+| [`fopen`, `_wfopen`](reference/fopen-wfopen.md), [`fopen_s`, `_wfopen_s`](reference/fopen-s-wfopen-s.md) | Open stream |
+| [`fprintf`, `_fprintf_l`, `fwprintf`, `_fwprintf_l`](reference/fprintf-fprintf-l-fwprintf-fwprintf-l.md), [`fprintf_s`, `_fprintf_s_l`, `fwprintf_s`, `_fwprintf_s_l`](reference/fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md) | Write formatted data to stream |
+| [`fputc`, `fputwc`](reference/fputc-fputwc.md) | Write a character to a stream (function versions of **`putc`** and **`putwc`**) |
+| [`_fputchar`, `_fputwchar`](reference/fputc-fputwc.md) | Write character to **`stdout`** (function versions of **`putchar`** and **`putwchar`**) |
+| [`fputs`, `fputws`](reference/fputs-fputws.md) | Write string to stream |
+| [`fread`](reference/fread.md) | Read unformatted data from stream |
+| [`freopen`, `_wfreopen`](reference/freopen-wfreopen.md), [`freopen_s`, `_wfreopen_s`](reference/freopen-s-wfreopen-s.md) | Reassign `FILE` stream pointer to new file or device |
+| [`fscanf`, `fwscanf`](reference/fscanf-fscanf-l-fwscanf-fwscanf-l.md), [`fscanf_s`, `_fscanf_s_l`, `fwscanf_s`, `_fwscanf_s_l`](reference/fscanf-s-fscanf-s-l-fwscanf-s-fwscanf-s-l.md) | Read formatted data from stream |
+| [`fseek`, `_fseeki64`](reference/fseek-fseeki64.md) | Move file position to given location |
+| [`fsetpos`](reference/fsetpos.md) | Set position indicator of stream |
+| [`_fsopen`, `_wfsopen`](reference/fsopen-wfsopen.md) | Open stream with file sharing |
+| [`ftell`, `_ftelli64`](reference/ftell-ftelli64.md) | Get current file position |
+| [`fwrite`](reference/fwrite.md) | Write unformatted data items to stream |
+| [`getc`, `getwc`](reference/getc-getwc.md) | Read character from stream (macro versions of **`fgetc`** and **`fgetwc`**) |
+| [`getchar`, `getwchar`](reference/getc-getwc.md) | Read character from **`stdin`** (macro versions of **`fgetchar`** and **`fgetwchar`**) |
+| [`_getmaxstdio`](reference/getmaxstdio.md) | Returns the number of simultaneously open files permitted at the stream I/O level. |
+| [`gets_s`, `_getws_s`](reference/gets-s-getws-s.md) | Read line from **`stdin`** |
+| [`_getw`](reference/getw.md) | Read binary **`int`** from stream |
+| [`printf`, `_printf_l`, `wprintf`, `_wprintf_l`](reference/printf-printf-l-wprintf-wprintf-l.md), [`printf_s`, `_printf_s_l`, `wprintf_s`, `_wprintf_s_l`](reference/printf-s-printf-s-l-wprintf-s-wprintf-s-l.md) | Write formatted data to **`stdout`** |
+| [`putc`, `putwc`](reference/putc-putwc.md) | Write character to a stream (macro versions of **`fputc`** and **`fputwc`**) |
+| [`putchar`, `putwchar`](reference/putc-putwc.md) | Write character to **`stdout`** (macro versions of **`fputchar`** and **`fputwchar`**) |
+| [`puts`, `_putws`](reference/puts-putws.md) | Write line to stream |
+| [`_putw`](reference/putw.md) | Write binary **`int`** to stream |
+| [`rewind`](reference/rewind.md) | Move file position to beginning of stream |
+| [`_rmtmp`](reference/rmtmp.md) | Remove temporary files created by **`tmpfile`** |
+| [`scanf`, `_scanf_l`, `wscanf`, `_wscanf_l`](reference/scanf-scanf-l-wscanf-wscanf-l.md), [`scanf_s`, `_scanf_s_l`, `wscanf_s`, `_wscanf_s_l`](reference/scanf-s-scanf-s-l-wscanf-s-wscanf-s-l.md) | Read formatted data from **`stdin`** |
+| [`setbuf`](reference/setbuf.md) | Control stream buffering |
+| [`_setmaxstdio`](reference/setmaxstdio.md) | Set a maximum for the number of simultaneously open files at the stream I/O level. |
+| [`setvbuf`](reference/setvbuf.md) | Control stream buffering and buffer size |
+| [`_snprintf`, `_snwprintf`](reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md), [`_snprintf_s`, `_snprintf_s_l`, `_snwprintf_s`, `_snwprintf_s_l`](reference/snprintf-s-snprintf-s-l-snwprintf-s-snwprintf-s-l.md) | Write formatted data of specified length to string |
+| [`_snscanf`, `_snwscanf`](reference/snscanf-snscanf-l-snwscanf-snwscanf-l.md), [`_snscanf_s`, `_snscanf_s_l`, `_snwscanf_s`, `_snwscanf_s_l`](reference/snscanf-s-snscanf-s-l-snwscanf-s-snwscanf-s-l.md) | Read formatted data of a specified length from the standard input stream. |
+| [`sprintf`, `swprintf`](reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md), [`sprintf_s`, `_sprintf_s_l`, `swprintf_s`, `_swprintf_s_l`](reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md) | Write formatted data to string |
+| [`sscanf`, `swscanf`](reference/sscanf-sscanf-l-swscanf-swscanf-l.md), [`sscanf_s`, _sscanf_s_l, `swscanf_s`, `_swscanf_s_l`](reference/sscanf-s-sscanf-s-l-swscanf-s-swscanf-s-l.md) | Read formatted data from string |
+| [`_tempnam`, `_wtempnam`](reference/tempnam-wtempnam-tmpnam-wtmpnam.md) | Generate temporary filename in given directory |
+| [`tmpfile`](reference/tmpfile.md), [`tmpfile_s`](reference/tmpfile-s.md) | Create temporary file |
+| [`tmpnam`, `_wtmpnam`](reference/tempnam-wtempnam-tmpnam-wtmpnam.md), [`tmpnam_s`, `_wtmpnam_s`](reference/tmpnam-s-wtmpnam-s.md) | Generate temporary filename |
+| [`ungetc`, `ungetwc`](reference/ungetc-ungetwc.md) | Push character back onto stream |
+| [`_vcprintf`, `_vcwprintf`](reference/vcprintf-vcprintf-l-vcwprintf-vcwprintf-l.md), [`_vcprintf_s`, `_vcprintf_s_l`, `_vcwprintf_s`, `_vcwprintf_s_l`](reference/vcprintf-s-vcprintf-s-l-vcwprintf-s-vcwprintf-s-l.md) | Write formatted data to the console. |
+| [`vfprintf`, `vfwprintf`](reference/vfprintf-vfprintf-l-vfwprintf-vfwprintf-l.md), [`vfprintf_s`, `_vfprintf_s_l`, `vfwprintf_s`, `_vfwprintf_s_l`](reference/vfprintf-s-vfprintf-s-l-vfwprintf-s-vfwprintf-s-l.md) | Write formatted data to stream |
+| [`vprintf`, `vwprintf`](reference/vprintf-vprintf-l-vwprintf-vwprintf-l.md), [`vprintf_s`, `_vprintf_s_l`, `vwprintf_s`, `_vwprintf_s_l`](reference/vprintf-s-vprintf-s-l-vwprintf-s-vwprintf-s-l.md) | Write formatted data to **`stdout`** |
+| [`_vsnprintf`, `_vsnwprintf`](reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md), [`vsnprintf_s`, `_vsnprintf_s`, `_vsnprintf_s_l`, `_vsnwprintf_s`, `_vsnwprintf_s_l`](reference/vsnprintf-s-vsnprintf-s-vsnprintf-s-l-vsnwprintf-s-vsnwprintf-s-l.md) | Write formatted data of specified length to buffer |
+| [`vsprintf`, `vswprintf`](reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md), [`vsprintf_s`, `_vsprintf_s_l`, `vswprintf_s`, `_vswprintf_s_l`](reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md) | Write formatted data to buffer |
When a program begins execution, the startup code automatically opens several streams: standard input (pointed to by **`stdin`**), standard output (pointed to by **`stdout`**), and standard error (pointed to by **`stderr`**). These streams are directed to the console (keyboard and screen) by default. Use **`freopen`** to redirect **`stdin`**, **`stdout`**, or **`stderr`** to a disk file or a device.
@@ -76,16 +75,15 @@ Files opened using the stream routines are buffered by default. The **`stdout`**
There are two ways to commit buffer contents to disk:
- Link with the file COMMODE.OBJ to set a global commit flag. The default setting of the global flag is **`n`**, for "no-commit."
-
- Set the mode flag to **`c`** with **`fopen`** or **`_fdopen`**.
Any file specifically opened with either the **`c`** or the **`n`** flag behaves according to the flag, regardless of the state of the global commit/no-commit flag.
-If your program doesn't explicitly close a stream, the stream is automatically closed when the program terminates. However, you should close a stream when your program finishes with it, as the number of streams that can be open at one time is limited. See [`_setmaxstdio`](./reference/setmaxstdio.md) for information on this limit.
+If your program doesn't explicitly close a stream, the stream is automatically closed when the program terminates. However, you should close a stream when your program finishes with it, as the number of streams that can be open at one time is limited. See [`_setmaxstdio`](reference/setmaxstdio.md) for information on this limit.
Input can follow output directly only with an intervening call to **`fflush`** or to a file-positioning function (**`fseek`**, **`fsetpos`**, or **`rewind`**). Input can be followed by output without an intervening call to a file-positioning function, if the input operation encounters the end of the file.
## See also
-[Input and output](./input-and-output.md)\
-[Universal C runtime routines by category](./run-time-routines-by-category.md)
+[Input and output](input-and-output.md)\
+[Universal C runtime routines by category](run-time-routines-by-category.md)
diff --git a/docs/c-runtime-library/text-and-binary-mode-file-i-o.md b/docs/c-runtime-library/text-and-binary-mode-file-i-o.md
index 7a3cde2713..f21bfaef2a 100644
--- a/docs/c-runtime-library/text-and-binary-mode-file-i-o.md
+++ b/docs/c-runtime-library/text-and-binary-mode-file-i-o.md
@@ -11,7 +11,7 @@ File I/O operations take place in one of two translation modes, *text* or *binar
- Retain the current default setting and specify the alternative mode only when you open selected files.
-- Use the function [`_set_fmode`](./reference/set-fmode.md) to change the default mode for newly opened files. Use [`_get_fmode`](./reference/get-fmode.md) to find the current default mode. The initial default setting is text mode (`_O_TEXT`).
+- Use the function [`_set_fmode`](./reference/set-fmode.md) to change the default mode for newly opened files. Use [`_get_fmode`](./reference/get-fmode.md) to find the current default mode. The initial default setting is ANSI text mode (`_O_TEXT`).
- Change the default translation mode directly by setting the global variable [`_fmode`](./fmode.md) in your program. The function `_set_fmode` sets the value of this variable, but it can also be set directly.
diff --git a/docs/c-runtime-library/time-management.md b/docs/c-runtime-library/time-management.md
index 784c4b009a..619798b3cc 100644
--- a/docs/c-runtime-library/time-management.md
+++ b/docs/c-runtime-library/time-management.md
@@ -1,42 +1,42 @@
---
-description: "Learn more about: Time Management"
title: "Time Management"
-ms.date: "11/04/2016"
+description: "Learn more about: Time Management"
+ms.date: 11/04/2016
helpviewer_keywords: ["dates, run-time library members", "time, time management", "date functions", "time functions"]
---
# Time management
Use these functions to get the current time and convert, adjust, and store it as necessary. The current time is the system time.
-The **`_ftime`** and **`localtime`** routines use the **`TZ`** environment variable. If **`TZ`** isn't set, the run-time library attempts to use the time-zone information specified by the operating system. If this information is unavailable, these functions use the default value of PST8PDT. For more information on **`TZ`**, see [`_tzset`](./reference/tzset.md); also see [`_daylight`, `timezone`, and `_tzname`](./daylight-dstbias-timezone-and-tzname.md).
+The **`_ftime`** and **`localtime`** routines use the **`TZ`** environment variable. If **`TZ`** isn't set, the run-time library attempts to use the time-zone information specified by the operating system. If this information is unavailable, these functions use the default value of PST8PDT. For more information on **`TZ`**, see [`_tzset`](reference/tzset.md); also see [`_daylight`, `timezone`, and `_tzname`](daylight-dstbias-timezone-and-tzname.md).
### Time routines
| Function | Use |
|---|---|
-| [`asctime`, `_wasctime`](./reference/asctime-wasctime.md), [`asctime_s`, `_wasctime_s`](./reference/asctime-s-wasctime-s.md) | Convert time from type **`struct tm`** to character string. The versions of these functions with the **`_s`** suffix are more secure. |
-| [`clock`](./reference/clock.md) | Return elapsed wall-clock time for process. |
-| [`ctime`, `_ctime32`, `_ctime64`, `_wctime`, `_wctime32`, `_wctime64`](./reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64.md), [`_ctime_s`, `_ctime32_s`, `_ctime64_s`, `_wctime_s`, `_wctime32_s`, `_wctime64_s`](./reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md) | Convert time from type **`time_t`**, **`__time32_t`** or **`__time64_t`** to character string. The versions of these functions with the **`_s`** suffix are more secure. |
-| [`difftime`, `_difftime32`, `_difftime64`](./reference/difftime-difftime32-difftime64.md) | Compute difference between two times. |
-| [`_ftime`, `_ftime32`, `_ftime64`](./reference/ftime-ftime32-ftime64.md),[`_ftime_s`, `_ftime32_s`, _ftime64_s](./reference/ftime-s-ftime32-s-ftime64-s.md) | Store current system time in variable of type **`struct _timeb`** or type **`struct __timeb64`** The versions of these functions with the **`_s`** suffix are more secure. |
-| [`_futime`, `_futime32`, `_futime64`](./reference/futime-futime32-futime64.md) | Set modification time on open file |
-| [`gmtime`, `_gmtime32`, `_gmtime64`](./reference/gmtime-gmtime32-gmtime64.md), [`gmtime_s`, `_gmtime32_s`, `_gmtime64_s`](./reference/gmtime-s-gmtime32-s-gmtime64-s.md) | Convert time from type **`time_t`** to **`struct tm`** or from type **`__time64_t`** to **`struct tm`**. The versions of these functions with the **`_s`** suffix are more secure. |
-| [`localtime`, `_localtime32`, `_localtime64`](./reference/localtime-localtime32-localtime64.md), [`localtime_s`, `_localtime32_s`, `_localtime64_s`](./reference/localtime-s-localtime32-s-localtime64-s.md) | Convert time from type **`time_t`** to **`struct tm`** or from type **`__time64_t`** to **`struct tm`** with local correction. The versions of these functions with the **`_s`** suffix are more secure. |
-| [`_mkgmtime`, `_mkgmtime32`, `_mkgmtime64`](./reference/mkgmtime-mkgmtime32-mkgmtime64.md) | Convert time to calendar value in Greenwich Mean Time. |
-| [`mktime`, `_mktime32`, `_mktime64`](./reference/mktime-mktime32-mktime64.md) | Convert time to calendar value. |
-| [`_strdate`, `_wstrdate`](./reference/strdate-wstrdate.md), [`_strdate_s`, `_wstrdate_s`](./reference/strdate-s-wstrdate-s.md) | Return current system date as string. The versions of these functions with the **`_s`** suffix are more secure. |
-| [`strftime`, `wcsftime`, `_strftime_l`, `_wcsftime_l`](./reference/strftime-wcsftime-strftime-l-wcsftime-l.md) | Format date-and-time string for international use. |
-| [`_strtime`, `_wstrtime`](./reference/strtime-wstrtime.md), [`_strtime_s`, `_wstrtime_s`](./reference/strtime-s-wstrtime-s.md) | Return current system time as string. The versions of these functions with the **`_s`** suffix are more secure. |
-| [`time`, `_time32`, `_time64`](./reference/time-time32-time64.md) | Get current system time as type **`time_t`**, **`__time32_t`** or as type **`__time64_t`**. |
-| [`_tzset`](./reference/tzset.md) | Set external time variables from environment time variable **`TZ`**. |
-| [`_utime`, `_utime32`, `_utime64`, `_wutime`, `_wutime32`, `_wutime64`](./reference/utime-utime32-utime64-wutime-wutime32-wutime64.md) | Set modification time for specified file using either current time or time value stored in structure. |
+| [`asctime`, `_wasctime`](reference/asctime-wasctime.md), [`asctime_s`, `_wasctime_s`](reference/asctime-s-wasctime-s.md) | Convert time from type **`struct tm`** to character string. The versions of these functions with the **`_s`** suffix are more secure. |
+| [`clock`](reference/clock.md) | Return elapsed wall-clock time for process. |
+| [`ctime`, `_ctime32`, `_ctime64`, `_wctime`, `_wctime32`, `_wctime64`](reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64.md), [`_ctime_s`, `_ctime32_s`, `_ctime64_s`, `_wctime_s`, `_wctime32_s`, `_wctime64_s`](reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md) | Convert time from type **`time_t`**, **`__time32_t`** or **`__time64_t`** to character string. The versions of these functions with the **`_s`** suffix are more secure. |
+| [`difftime`, `_difftime32`, `_difftime64`](reference/difftime-difftime32-difftime64.md) | Compute difference between two times. |
+| [`_ftime`, `_ftime32`, `_ftime64`](reference/ftime-ftime32-ftime64.md), [`_ftime_s`, `_ftime32_s`, _ftime64_s](reference/ftime-s-ftime32-s-ftime64-s.md) | Store current system time in variable of type **`struct _timeb`** or type **`struct __timeb64`** The versions of these functions with the **`_s`** suffix are more secure. |
+| [`_futime`, `_futime32`, `_futime64`](reference/futime-futime32-futime64.md) | Set modification time on open file |
+| [`gmtime`, `_gmtime32`, `_gmtime64`](reference/gmtime-gmtime32-gmtime64.md), [`gmtime_s`, `_gmtime32_s`, `_gmtime64_s`](reference/gmtime-s-gmtime32-s-gmtime64-s.md) | Convert time from type **`time_t`** to **`struct tm`** or from type **`__time64_t`** to **`struct tm`**. The versions of these functions with the **`_s`** suffix are more secure. |
+| [`localtime`, `_localtime32`, `_localtime64`](reference/localtime-localtime32-localtime64.md), [`localtime_s`, `_localtime32_s`, `_localtime64_s`](reference/localtime-s-localtime32-s-localtime64-s.md) | Convert time from type **`time_t`** to **`struct tm`** or from type **`__time64_t`** to **`struct tm`** with local correction. The versions of these functions with the **`_s`** suffix are more secure. |
+| [`_mkgmtime`, `_mkgmtime32`, `_mkgmtime64`](reference/mkgmtime-mkgmtime32-mkgmtime64.md) | Convert time to calendar value in Greenwich Mean Time. |
+| [`mktime`, `_mktime32`, `_mktime64`](reference/mktime-mktime32-mktime64.md) | Convert time to calendar value. |
+| [`_strdate`, `_wstrdate`](reference/strdate-wstrdate.md), [`_strdate_s`, `_wstrdate_s`](reference/strdate-s-wstrdate-s.md) | Return current system date as string. The versions of these functions with the **`_s`** suffix are more secure. |
+| [`strftime`, `wcsftime`, `_strftime_l`, `_wcsftime_l`](reference/strftime-wcsftime-strftime-l-wcsftime-l.md) | Format date-and-time string for international use. |
+| [`_strtime`, `_wstrtime`](reference/strtime-wstrtime.md), [`_strtime_s`, `_wstrtime_s`](reference/strtime-s-wstrtime-s.md) | Return current system time as string. The versions of these functions with the **`_s`** suffix are more secure. |
+| [`time`, `_time32`, `_time64`](reference/time-time32-time64.md) | Get current system time as type **`time_t`**, **`__time32_t`** or as type **`__time64_t`**. |
+| [`_tzset`](reference/tzset.md) | Set external time variables from environment time variable **`TZ`**. |
+| [`_utime`, `_utime32`, `_utime64`, `_wutime`, `_wutime32`, `_wutime64`](reference/utime-utime32-utime64-wutime-wutime32-wutime64.md) | Set modification time for specified file using either current time or time value stored in structure. |
> [!NOTE]
> In all versions of Microsoft C/C++ except Microsoft C/C++ version 7.0, and in all versions of Visual C++, the time function returns the current time as the number of seconds elapsed since midnight on January 1, 1970. In Microsoft C/C++ version 7.0, **`time`** returned the current time as the number of seconds elapsed since midnight on December 31, 1899.
> [!NOTE]
-> In versions of Visual C++ and Microsoft C/C++ before Visual Studio 2005, **`time_t`** was a **`long int`** (32 bits) and hence could not be used for dates past 3:14:07 January 19, 2038, UTC. **`time_t`** is now equivalent to **`__time64_t`** by default, but defining `_USE_32BIT_TIME_T` changes **`time_t`** to **`__time32_t`** and forces many time functions to call versions that take the 32-bit **`time_t`**. For more information, see [Standard types](./standard-types.md) and comments in the documentation for the individual time functions.
+> In versions of Visual C++ and Microsoft C/C++ before Visual Studio 2005, **`time_t`** was a **`long int`** (32 bits) and hence could not be used for dates past 3:14:07 January 19, 2038, UTC. **`time_t`** is now equivalent to **`__time64_t`** by default, but defining `_USE_32BIT_TIME_T` changes **`time_t`** to **`__time32_t`** and forces many time functions to call versions that take the 32-bit **`time_t`**. For more information, see [Standard types](standard-types.md) and comments in the documentation for the individual time functions.
## See also
-[Universal C runtime routines by category](./run-time-routines-by-category.md)
+[Universal C runtime routines by category](run-time-routines-by-category.md)
diff --git a/docs/c-runtime-library/to-functions.md b/docs/c-runtime-library/to-functions.md
index ac4ca2224a..3cd86e5a53 100644
--- a/docs/c-runtime-library/to-functions.md
+++ b/docs/c-runtime-library/to-functions.md
@@ -1,9 +1,8 @@
---
description: "Learn more about: to Functions"
title: "to Functions"
-ms.date: "11/04/2016"
+ms.date: 06/15/2023
helpviewer_keywords: ["to functions", "string conversion, to different characters", "string conversion, case", "lowercase, converting strings", "uppercase, converting strings", "case, converting", "characters, converting"]
-ms.assetid: f636a4c6-8c9f-4be2-baac-064f9dbae300
---
# `to` functions
@@ -27,28 +26,24 @@ The **`to`** functions and macro conversions are as follows.
| `_toupper` | `_toupper` | Converts `c` to uppercase |
| `towupper` | None | Converts c to corresponding wide-character uppercase letter |
-To use the function versions of the **`to`** routines that are also defined as macros, either remove the macro definitions with `#undef` directives or don't include CTYPE.H. If you use the /Za compiler option, the compiler uses the function version of `toupper` or `tolower`. Declarations of the `toupper` and `tolower` functions are in STDLIB.H.
+To use the function versions of the **`to`** routines that are also defined as macros, either remove the macro definitions with `#undef` directives or don't include `CTYPE.H`. If you use the /Za compiler option, the compiler uses the function version of `toupper` or `tolower`. Declarations of the `toupper` and `tolower` functions are in `STDLIB.H`.
The `__toascii` routine sets all but the low-order 7 bits of `c` to 0, so that the converted value represents a character in the ASCII character set. If `c` already represents an ASCII character, `c` is unchanged.
The `tolower` and `toupper` routines:
- Are dependent on the `LC_CTYPE` category of the current locale (`tolower` calls `isupper` and `toupper` calls `islower`).
-
- Convert `c` if `c` represents a convertible letter of the appropriate case in the current locale and the opposite case exists for that locale. Otherwise, `c` is unchanged.
The `_tolower` and `_toupper` routines:
- Are locale-independent, much faster versions of `tolower` and **toupper.**
-
- Can be used only when **isascii(**`c`**)** and either **isupper(**`c`**)** or **islower(**`c`**)**, respectively, are nonzero.
-
- Have undefined results if `c` isn't an ASCII letter of the appropriate case for converting.
The `towlower` and `towupper` functions return a converted copy of `c` if and only if both of the following conditions are nonzero. Otherwise, `c` is unchanged.
- `c` is a wide character of the appropriate case (that is, for which `iswupper` or **iswlower,** respectively, is nonzero).
-
- There's a corresponding wide character of the target case (that is, for which `iswlower` or **iswupper,** respectively, is nonzero).
## Example
@@ -63,8 +58,9 @@ The `towlower` and `towupper` functions return a converted copy of `c` if and on
#include
#include
+#include
-char msg[] = "Some of THESE letters are Capitals.";
+char msg[] = "Some of THESE letters are Uppercase.";
char *p;
int main( void )
@@ -85,12 +81,12 @@ int main( void )
```
```Output
-Some of THESE letters are Capitals.
-sOME OF these LETTERS ARE cAPITALS.
+Some of THESE letters are Uppercase.
+sOME OF these LETTERS ARE uPPERCASE.
```
## See also
[Data conversion](./data-conversion.md)\
-[Locale](./locale.md)\
+[`Locale`](./locale.md)\
[`is`, `isw` routines](./is-isw-routines.md)
diff --git a/docs/c-runtime-library/toc.yml b/docs/c-runtime-library/toc.yml
index b4497d6277..4eb9c708b3 100644
--- a/docs/c-runtime-library/toc.yml
+++ b/docs/c-runtime-library/toc.yml
@@ -385,7 +385,7 @@ items:
href: ../c-runtime-library/data-type-mappings.md
- name: Constant and global variable mappings
href: ../c-runtime-library/constant-and-global-variable-mappings.md
- - name: Routine mappings
+ - name: Generic-text function mappings
href: ../c-runtime-library/routine-mappings.md
- name: Locale names, languages, and country-region strings
expanded: false
@@ -475,9 +475,9 @@ items:
href: ../c-runtime-library/reference/abs-labs-llabs-abs64.md
- name: access (CRT)
href: ../c-runtime-library/reference/access-crt.md
- - name: _access, _waccess
+ - name: _access, _waccess, taccess_s
href: ../c-runtime-library/reference/access-waccess.md
- - name: _access_s, _waccess_s
+ - name: _access_s, _waccess_s, _taccess_s
href: ../c-runtime-library/reference/access-s-waccess-s.md
- name: acos, acosf, acosl
href: ../c-runtime-library/reference/acos-acosf-acosl.md
@@ -945,11 +945,11 @@ items:
href: ../c-runtime-library/reference/fpieee-flt.md
- name: _fpreset
href: ../c-runtime-library/reference/fpreset.md
- - name: fprintf, _fprintf_l, fwprintf, _fwprintf_l
+ - name: fprintf, _fprintf_l, fwprintf, _fwprintf_l, _ftprintf, _ftprintf_l
href: ../c-runtime-library/reference/fprintf-fprintf-l-fwprintf-fwprintf-l.md
- - name: _fprintf_p, _fprintf_p_l, _fwprintf_p, _fwprintf_p_l
+ - name: _fprintf_p, _fprintf_p_l, _ftprintf_p, _ftprintf_p_l, _fwprintf_p, _fwprintf_p_l
href: ../c-runtime-library/reference/fprintf-p-fprintf-p-l-fwprintf-p-fwprintf-p-l.md
- - name: fprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_l
+ - name: fprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_l, _ftprintf, _ftprintf_l, _ftprintf_s, _ftprintf_s_l
href: ../c-runtime-library/reference/fprintf-s-fprintf-s-l-fwprintf-s-fwprintf-s-l.md
- name: fputc, fputwc
href: ../c-runtime-library/reference/fputc-fputwc.md
@@ -1457,7 +1457,7 @@ items:
href: ../c-runtime-library/reference/putenv.md
- name: _putenv, _wputenv
href: ../c-runtime-library/reference/putenv-wputenv.md
- - name: _putenv_s, _wputenv_s
+ - name: _putenv_s, _wputenv_s, _tputenv_s
href: ../c-runtime-library/reference/putenv-s-wputenv-s.md
- name: puts, _putws
href: ../c-runtime-library/reference/puts-putws.md
@@ -1737,7 +1737,7 @@ items:
href: ../c-runtime-library/reference/strncoll-wcsncoll-mbsncoll-strncoll-l-wcsncoll-l-mbsncoll-l.md
- name: strncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l
href: ../c-runtime-library/reference/strncpy-strncpy-l-wcsncpy-wcsncpy-l-mbsncpy-mbsncpy-l.md
- - name: strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l
+ - name: strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l, _tcsncpy_s, _tcsncpy_s_l, _tcsnccpy_s, _tcsnccpy_s_l
href: ../c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md
- name: _strnextc, _wcsnextc, _mbsnextc, _mbsnextc_l
href: ../c-runtime-library/reference/strnextc-wcsnextc-mbsnextc-mbsnextc-l.md
@@ -1755,7 +1755,7 @@ items:
href: ../c-runtime-library/reference/strnset-wcsnset.md
- name: _strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l
href: ../c-runtime-library/reference/strnset-strnset-l-wcsnset-wcsnset-l-mbsnset-mbsnset-l.md
- - name: _strnset_s, _strnset_s_l, _wcsnset_s, _wcsnset_s_l, _mbsnset_s, _mbsnset_s_l
+ - name: _strnset_s, _strnset_s_l, _wcsnset_s, _wcsnset_s_l, _mbsnset_s, _mbsnset_s_l, _tcsnset_s, _tcsncset_s, _tcsncset_s_l
href: ../c-runtime-library/reference/strnset-s-strnset-s-l-wcsnset-s-wcsnset-s-l-mbsnset-s-mbsnset-s-l.md
- name: strpbrk, wcspbrk, _mbspbrk, _mbspbrk_l
href: ../c-runtime-library/reference/strpbrk-wcspbrk-mbspbrk-mbspbrk-l.md
@@ -1929,7 +1929,7 @@ items:
href: ../c-runtime-library/reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md
- name: _vsprintf_p, _vsprintf_p_l, _vswprintf_p, _vswprintf_p_l
href: ../c-runtime-library/reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l.md
- - name: vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l
+ - name: vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l, _vstprintf_s, _vstprintf_s_l
href: ../c-runtime-library/reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md
- name: vsscanf, vswscanf
href: ../c-runtime-library/reference/vsscanf-vswscanf.md
diff --git a/docs/c-runtime-library/translation-mode-constants.md b/docs/c-runtime-library/translation-mode-constants.md
index 1cd90a6225..b50e64e560 100644
--- a/docs/c-runtime-library/translation-mode-constants.md
+++ b/docs/c-runtime-library/translation-mode-constants.md
@@ -22,10 +22,10 @@ The allowed values are:
| Value | Description |
|---|---|
-| `_O_TEXT` | Opens file in text (translated) mode. Carriage return-line feed (CR-LF) combinations are translated into a single line feed (LF) on input. Line feed characters are translated into CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading, and for reading and writing, `fopen` checks for CTRL+Z at the end of the file and removes it, if possible. It's removed because using the `fseek` and `ftell` functions to move within a file ending with CTRL+Z may cause `fseek` to behave improperly near the end of the file. |
-| `_O_WTEXT` | Opens file in UTF16 (translated) mode. The wide-character versions of the text translations of `_O_TEXT` are supported. |
-| `_O_U16TEXT` | Opens file in UTF16 no BOM (translated) mode. The wide-character versions of the text translations of `_O_TEXT` are supported. |
-| `_O_U8TEXT` | Opens file in UTF8 no BOM (translated) mode. The text translations of `_O_TEXT` are supported. |
+| `_O_TEXT` | Opens file in ANSI text (translated) mode. Carriage return-line feed (CR-LF) combinations are translated into a single line feed (LF) on input. Line feed characters are translated into CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading, and for reading and writing, `fopen` checks for CTRL+Z at the end of the file and removes it, if possible. It's removed because using the `fseek` and `ftell` functions to move within a file ending with CTRL+Z may cause `fseek` to behave improperly near the end of the file. |
+| `_O_WTEXT` | Opens file in UTF-16 text (translated) mode. The wide-character versions of the text translations of `_O_TEXT` are supported. |
+| `_O_U16TEXT` | Opens file in UTF-16 no BOM text (translated) mode. The wide-character versions of the text translations of `_O_TEXT` are supported. |
+| `_O_U8TEXT` | Opens file in UTF-8 no BOM text (translated) mode. The text translations of `_O_TEXT` are supported. |
| `_O_BINARY` | Opens file in binary (untranslated) mode. The above translations are suppressed. |
| `_O_RAW` | Same as `_O_BINARY`. Supported for C 2.0 compatibility. |
diff --git a/docs/c-runtime-library/unicode-the-wide-character-set.md b/docs/c-runtime-library/unicode-the-wide-character-set.md
index a45fbb30f3..9fbde6648e 100644
--- a/docs/c-runtime-library/unicode-the-wide-character-set.md
+++ b/docs/c-runtime-library/unicode-the-wide-character-set.md
@@ -8,7 +8,7 @@ ms.assetid: b6a05a21-59a5-4d30-8c85-2dbe185f7a74
---
# Unicode: The wide-character set
-A wide character is a 2-byte multilingual character code. Any character in use in modern computing worldwide, including technical symbols and special publishing characters, can be represented according to the Unicode specification as a wide character. Developed and maintained by a large consortium that includes Microsoft, the Unicode standard is now widely accepted.
+A wide character is a 2-byte multilingual character code. Any character in use in modern computing worldwide, including technical symbols and special publishing characters, can be represented according to the Unicode specification as one or more wide characters. Developed and maintained by a large consortium that includes Microsoft, the Unicode standard is now widely accepted.
A wide character is of type **`wchar_t`**. A wide-character string is represented as a **`wchar_t[]`** array. You point to the array with a `wchar_t*` pointer.
diff --git a/docs/c-runtime-library/vprintf-functions.md b/docs/c-runtime-library/vprintf-functions.md
index bc1cb41d24..6119ea7428 100644
--- a/docs/c-runtime-library/vprintf-functions.md
+++ b/docs/c-runtime-library/vprintf-functions.md
@@ -1,9 +1,8 @@
---
-description: "Learn more about: vprintf Functions"
title: "vprintf Functions"
+description: "Learn more about: vprintf Functions"
ms.date: "11/04/2016"
helpviewer_keywords: ["vprintf functions", "formatted text [C++]"]
-ms.assetid: 02ac7c51-eab1-4bf0-bf4c-77065e3fa744
---
# `vprintf` functions
@@ -17,7 +16,7 @@ Each of the `vprintf` functions takes a pointer to an argument list, then format
[`_vprintf_p`, `_vprintf_p_l`, `_vwprintf_p`, `_vwprintf_p_l`](./reference/vprintf-p-vprintf-p-l-vwprintf-p-vwprintf-p-l.md)\
[`vprintf_s`, `_vprintf_s_l`, `vwprintf_s`, `_vwprintf_s_l`](./reference/vprintf-s-vprintf-s-l-vwprintf-s-vwprintf-s-l.md)\
[`_vscprintf`, `_vscprintf_l`, `_vscwprintf`, `_vscwprintf_l`](./reference/vscprintf-vscprintf-l-vscwprintf-vscwprintf-l.md)\
-[`_vsnprintf`, `_vsnwprintf`](./reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md)
+[`_vsnprintf`, `_vsnwprintf`](./reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md)\
[`vsprintf`, `vswprintf`](./reference/vsprintf-vsprintf-l-vswprintf-vswprintf-l-vswprintf-l.md)\
[`_vsprintf_p`, `_vsprintf_p_l`, `_vswprintf_p`, `_vswprintf_p_l`](./reference/vsprintf-p-vsprintf-p-l-vswprintf-p-vswprintf-p-l.md)\
[`vsprintf_s`, `_vsprintf_s_l`, `vswprintf_s`, `_vswprintf_s_l`](./reference/vsprintf-s-vsprintf-s-l-vswprintf-s-vswprintf-s-l.md)
diff --git a/docs/cloud/cloud-and-web-programming-in-visual-cpp.md b/docs/cloud/cloud-and-web-programming-in-visual-cpp.md
index 8ae34ccfbc..f2c9b0519b 100644
--- a/docs/cloud/cloud-and-web-programming-in-visual-cpp.md
+++ b/docs/cloud/cloud-and-web-programming-in-visual-cpp.md
@@ -1,8 +1,7 @@
---
-description: "Learn more about: Cloud and Web Programming in Visual C++"
title: "Cloud and Web Programming in Visual C++"
+description: "Learn more about: Cloud and Web Programming in Visual C++"
ms.date: "05/14/2019"
-ms.assetid: b63611f1-9723-44d0-ba7f-c3ebef341313
ms.topic: "overview"
ms.custom: intro-overview
---
@@ -43,7 +42,7 @@ In C++, you have several options for connecting to the web and the cloud.
- [Windows::Web::Http::HttpClient](/uwp/api/windows.web.http.httpclient)
- A Windows Runtime HTTP client class modeled on the .NET Framework class of the same name in the System.Web namespace. `HttpClient` fully supports asynchronous upload and download over HTTP, and pipeline filters that enable the insertion of custom HTTP handlers into the pipeline. The Windows SDK includes sample filters for metered networks, OAuth authentication, and more. For apps that target only Universal Windows Platform, we recommend that you use the `Windows::Web:HttpClient` class.
+ A Windows Runtime HTTP client class modeled on the .NET Framework class of the same name in the System.Web namespace. `HttpClient` fully supports asynchronous upload and download over HTTP, and pipeline filters that enable the insertion of custom HTTP handlers into the pipeline. The Windows SDK includes sample filters for metered networks, OAuth authentication, and more. For apps that target only Universal Windows Platform, we recommend that you use the `Windows::Web::Http::HttpClient` class.
- [IXMLHTTPRequest2 interface](/windows/win32/api/msxml6/nn-msxml6-ixmlhttprequest2)
@@ -55,6 +54,6 @@ In C++, you have several options for connecting to the web and the cloud.
## See also
-[C++ in Visual Studio](../overview/visual-cpp-in-visual-studio.md)
-[Microsoft Azure C and C++ Developer Center](https://azure.microsoft.com/develop/cpp/)
+[C++ in Visual Studio](../overview/visual-cpp-in-visual-studio.md)\
+[Microsoft Azure C and C++ Developer Center](https://azure.microsoft.com/develop/cpp/)\
[Networks and web services (UWP)](/windows/uwp/networking/)
diff --git a/docs/code-quality/annotating-locking-behavior.md b/docs/code-quality/annotating-locking-behavior.md
index ddf60a045a..a362074bad 100644
--- a/docs/code-quality/annotating-locking-behavior.md
+++ b/docs/code-quality/annotating-locking-behavior.md
@@ -33,9 +33,9 @@ ms.assetid: 07769c25-9b97-4ab7-b175-d1c450308d7a
To avoid concurrency bugs in your multithreaded program, always follow an appropriate locking discipline and use SAL annotations.
-Concurrency bugs are notoriously hard to reproduce, diagnose, and debug because they're non-deterministic. Reasoning about thread interleaving is difficult at best, and becomes impractical when you're designing a body of code that has more than a few threads. Therefore, it's good practice to follow a locking discipline in your multithreaded programs. For example, obeying a lock order while acquiring multiple locks helps avoid deadlocks, and acquiring the proper guarding lock before accessing a shared resource helps prevent race conditions.
+Concurrency bugs are notoriously hard to reproduce, diagnose, and debug because they're nondeterministic. Reasoning about thread interleaving is difficult at best, and becomes impractical when you're designing a body of code that has more than a few threads. Therefore, it's good practice to follow a locking discipline in your multithreaded programs. For example, obeying a lock order while acquiring multiple locks helps avoid deadlocks, and acquiring the proper guarding lock before accessing a shared resource helps prevent race conditions.
-Unfortunately, seemingly simple locking rules can be surprisingly hard to follow in practice. A fundamental limitation in today's programming languages and compilers is that they do not directly support the specification and analysis of concurrency requirements. Programmers have to rely on informal code comments to express their intentions about how they use locks.
+Unfortunately, seemingly simple locking rules can be surprisingly hard to follow in practice. A fundamental limitation in today's programming languages and compilers is that they don't directly support the specification and analysis of concurrency requirements. Programmers have to rely on informal code comments to express their intentions about how they use locks.
Concurrency SAL annotations are designed to help you specify locking side effects, locking responsibility, data guardianship, lock order hierarchy, and other expected locking behavior. By making implicit rules explicit, SAL concurrency annotations provide a consistent way for you to document how your code uses locking rules. Concurrency annotations also enhance the ability of code analysis tools to find race conditions, deadlocks, mismatched synchronization operations, and other subtle concurrency errors.
@@ -64,10 +64,10 @@ The following table lists the locking annotations.
|`_Acquires_nonreentrant_lock_(expr)`|The lock that's named by `expr` is acquired. An error is reported if the lock is already held.|
|`_Acquires_shared_lock_(expr)`|Annotates a function and indicates that in post state the function increments by one the shared lock count of the lock object that's named by `expr`.|
|`_Create_lock_level_(name)`|A statement that declares the symbol `name` to be a lock level so that it may be used in the annotations `_Has_Lock_level_` and `_Lock_level_order_`.|
-|`_Has_lock_kind_(kind)`|Annotates any object to refine the type information of a resource object. Sometimes a common type is used for different kinds of resources and the overloaded type isn't sufficient to distinguish the semantic requirements among various resources. Here's a list of pre-defined `kind` parameters:
`_Lock_kind_mutex_`
Lock kind ID for mutexes.
`_Lock_kind_event_`
Lock kind ID for events.
`_Lock_kind_semaphore_`
Lock kind ID for semaphores.
`_Lock_kind_spin_lock_`
Lock kind ID for spin locks.
`_Lock_kind_critical_section_`
Lock kind ID for critical sections.|
+|`_Has_lock_kind_(kind)`|Annotates any object to refine the type information of a resource object. Sometimes a common type is used for different kinds of resources and the overloaded type isn't sufficient to distinguish the semantic requirements among various resources. Here's a list of predefined `kind` parameters:
`_Lock_kind_mutex_`
Lock kind ID for mutexes.
`_Lock_kind_event_`
Lock kind ID for events.
`_Lock_kind_semaphore_`
Lock kind ID for semaphores.
`_Lock_kind_spin_lock_`
Lock kind ID for spin locks.
`_Lock_kind_critical_section_`
Lock kind ID for critical sections.|
|`_Has_lock_level_(name)`|Annotates a lock object and gives it the lock level of `name`.|
|`_Lock_level_order_(name1, name2)`|A statement that gives the lock ordering between `name1` and `name2`. Locks that have level `name1` must be acquired before locks that have level `name2`.|
-|`_Post_same_lock_(expr1, expr2)`|Annotates a function and indicates that in post state the two locks, `expr1` and `expr2`, are treated as if they're the same lock object.|
+|`_Post_same_lock_(dst, src)`|Annotates a function and indicates that in post state the two locks, `dst` and `src`, are treated as if they're the same lock object, by applying lock properties from `src` to `dst`.|
|`_Releases_exclusive_lock_(expr)`|Annotates a function and indicates that in post state the function decrements by one the exclusive lock count of the lock object that's named by `expr`.|
|`_Releases_lock_(expr)`|Annotates a function and indicates that in post state the function decrements by one the lock count of the lock object that's named by `expr`.|
|`_Releases_nonreentrant_lock_(expr)`|The lock that's named by `expr` is released. An error is reported if the lock isn't currently held.|
@@ -97,17 +97,17 @@ The following table lists the annotations for shared data access.
|----------------|-----------------|
|`_Guarded_by_(expr)`|Annotates a variable and indicates that whenever the variable is accessed, the lock count of the lock object that's named by `expr` is at least one.|
|`_Interlocked_`|Annotates a variable and is equivalent to `_Guarded_by_(_Global_interlock_)`.|
-|`_Interlocked_operand_`|The annotated function parameter is the target operand of one of the various Interlocked functions. Those operands must have specific additional properties.|
+|`_Interlocked_operand_`|The annotated function parameter is the target operand of one of the various Interlocked functions. Those operands must have other specific properties.|
|`_Write_guarded_by_(expr)`|Annotates a variable and indicates that whenever the variable is modified, the lock count of the lock object that's named by `expr` is at least one.|
## Smart Lock and RAII Annotations
-Smart locks typically wrap native locks and manage their lifetime. The following table lists annotations that can be used with smart locks and RAII coding patterns with support for `move` semantics.
+Smart locks typically wrap native locks and manage their lifetime. The following table lists annotations that can be used with smart locks and Resource Acquisition Is Initialization (RAII) coding patterns with support for `move` semantics.
|Annotation|Description|
|----------------|-----------------|
-|`_Analysis_assume_smart_lock_acquired_(lock)`|Tells the analyzer to assume that a smart lock has been acquired. This annotation expects a reference lock type as its parameter.|
-|`_Analysis_assume_smart_lock_released_(lock)`|Tells the analyzer to assume that a smart lock has been released. This annotation expects a reference lock type as its parameter.|
+|`_Analysis_assume_smart_lock_acquired_(lock)`|Tells the analyzer to assume that a smart lock was acquired. This annotation expects a reference lock type as its parameter.|
+|`_Analysis_assume_smart_lock_released_(lock)`|Tells the analyzer to assume that a smart lock was released. This annotation expects a reference lock type as its parameter.|
|`_Moves_lock_(target, source)`|Describes a `move constructor` operation, which transfers lock state from the `source` object to the `target`. The `target` is considered a newly constructed object, so any state it had before is lost and replaced by the `source` state. The `source` is also reset to a clean state with no lock counts or aliasing target, but aliases pointing to it remain unchanged.|
|`_Replaces_lock_(target, source)`|Describes `move assignment operator` semantics where the target lock is released before transferring the state from the source. You can regard it as a combination of `_Moves_lock_(target, source)` preceded by a `_Releases_lock_(target)`.|
|`_Swaps_locks_(left, right)`|Describes the standard `swap` behavior, which assumes that objects `left` and `right` exchange their state. The state exchanged includes lock count and aliasing target, if present. Aliases that point to the `left` and `right` objects remain unchanged.|
diff --git a/docs/code-quality/annotating-structs-and-classes.md b/docs/code-quality/annotating-structs-and-classes.md
index 32669912be..1c19f33cdd 100644
--- a/docs/code-quality/annotating-structs-and-classes.md
+++ b/docs/code-quality/annotating-structs-and-classes.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Annotating Structs and Classes"
title: Annotating Structs and Classes
+description: "Learn more about: Annotating Structs and Classes"
ms.date: 06/28/2019
ms.topic: "conceptual"
f1_keywords:
@@ -19,7 +19,6 @@ f1_keywords:
- "_Field_size_full_"
- "_Field_size_full_opt_"
- "_Field_z_"
-ms.assetid: b8278a4a-c86e-4845-aa2a-70da21a1dd52
---
# Annotating Structs and Classes
@@ -52,13 +51,11 @@ You can annotate struct and class members by using annotations that act like inv
Applies to struct or class declaration. Indicates that a valid object of that type may be larger than the declared type, with the number of bytes being specified by `size`. For example:
```cpp
-
typedef _Struct_size_bytes_(nSize)
struct MyStruct {
size_t nSize;
...
};
-
```
The buffer size in bytes of a parameter `pM` of type `MyStruct *` is then taken to be:
diff --git a/docs/code-quality/build-reliable-secure-programs.md b/docs/code-quality/build-reliable-secure-programs.md
new file mode 100644
index 0000000000..83f1605db1
--- /dev/null
+++ b/docs/code-quality/build-reliable-secure-programs.md
@@ -0,0 +1,456 @@
+---
+title: Build reliable and secure C++ programs
+description: "Learn more about: Building reliable and secure C++ programs by applying NISTIR 8397 guidelines."
+ms.date: 04/25/2025
+ms.topic: "conceptual"
+---
+
+# Build reliable and secure C++ programs
+
+The United States government publication [NISTIR 8397: Guidelines on Minimum Standards for Developer Verification of Software](https://nvlpubs.nist.gov/nistpubs/ir/2021/NIST.IR.8397.pdf) contains excellent guidance on how to build reliable and secure software in any programming language.
+
+This document follows the same structure as NISTIR 8397. Each section:
+- summarizes how to use Microsoft developer products for C++ and other languages to meet that section's security needs, and
+- provides guidance to get the most value in each area.
+
+## 2.1 Threat modeling
+
+**Summary**
+
+Threat modeling is a valuable process, especially when applied in a way that scales to meet your development needs and that reduces noise.
+
+**Recommendations**
+
+Threat modeling should be one part of your dynamic Security Development Lifecycle (SDL). We suggest that for your product as a whole, for a specific feature, or for a major design or implementation change:
+
+- Have a solid, dynamic SDL that allows for early engagement with developer teams and rightsizing of approach.
+- Apply threat modeling in a targeted way. Apply threat modeling to all features, but tactically start with exposed, complex or critical features. Do apply it regularly instead as part of a top-down product review.
+- Apply threat modeling early (as with all security requirements), when there's still opportunity to change the design. Also, threat models serve as an input to other processes, such as attack surface reduction or designing for security. Threat models that are created later are at best "surveys" for pen test (penetration testing) or areas that need security testing such as fuzzing. After you create a baseline threat model, plan to continue iterating on it as the attack surface changes.
+- Use asset inventory and compliance to appropriately track what makes up a product, and track security artifacts (including threat models) along with the assets they apply to. This approach enables better automated risk assessment and focusing of security efforts on the specific components or features that change.
+- **In Azure**, the Microsoft Threat Modeling Tool was updated in 2022 for Azure development. For more information, see [Microsoft Threat Modeling Tool overview - Azure](/azure/security/develop/threat-modeling-tool)
+
+**Supporting factors and practices**
+
+To properly apply threat modeling and avoid underuse/overuse, we have found that the following core concepts need to be addressed first.
+
+*Development approach*
+
+First, understand the team's development approach. For teams with agile development workflows that push dozens of changes to production daily, it's not practical or reasonable to require a threat model update for every functional change. Instead, from the start when writing a feature's functional requirements, consider including a security requirements questionnaire. The questionnaire should focus on specific questions about the feature to determine what future aspects of your SDL apply. For example:
+- Does the feature make a major change in design of how we provide customer isolation in a multitenant environment? If so, consider performing a full threat model.
+- Does a new feature allow file uploads? If so, perhaps what's more appropriate is a web application security assessment.
+- Is this change primarily just a functional UI change? If so, perhaps nothing is needed beyond your traditional automated tooling.
+
+The security questionnaire results inform which SDL techniques to tie to which unit of development. It also informs development partners of the feature's SDL timelines, so they can collaborate at the right times.
+
+*Product inventory*
+
+Second, maintain a strong asset inventory of the products you're tasked with assessing. Products are growing in complexity. It's common to write software for connected devices that have:
+- sensors (such as passenger rail and vehicles),
+- bus-based networks that talk to other components in the vehicle (such as CANBUS or PROFIBUS),
+- wireless/cellular/Bluetooth for communication with customer devices and cloud back ends,
+- machine learning in the cloud feeding back into the device or a fleet management application,
+- and more.
+
+In such complex products, threat modeling is critical. Having a strong asset inventory lets you view the entire product stack to see the complete picture, and to see the key places that need to be evaluated for how a new or changed feature impacts product security.
+
+*Granularity and integration*
+
+Establish systems to measure compliance using clear metrics.
+- Regularly measure compliance for feature level development. Feature compliance generally should be measured with higher frequency and smaller granularity, sometimes even on the developer's system or at code commit/merge time.
+- Periodically evaluate security for the broader product in which a feature or component is being consumed. Broader evaluations typically are done with lower frequency and broader granularity, such as at module or system testing time.
+
+*Scale*
+
+Keep a proper asset inventory system that captures and preserves security artifacts and the output of threat model reviews. Having a clear inventory lets you evaluate review outputs for patterns, and make intelligent decisions on how to refine the product security program regularly.
+
+Try to combine requirements-phase security questionnaires, threat modeling results, security assessment results, and results from automated tools. Combining them enables you to automate a viewpoint of relative risk of a given product, ideally as a "dashboard," to inform your security teams what to focus on to get the best value out of the threat modeling.
+
+## 2.2 Automated testing
+
+**Summary**
+
+Automated tests are an important way to ensure the quality and safety of your code. They're an integral piece in supporting other areas mentioned in this document, such as Threat Modeling. When paired with other secure coding practices, they help to protect against bugs and vulnerabilities being introduced into the codebase.
+
+**Key attributes**
+
+Tests should be reliable, consistent, and isolated. These tests should cover as much of the code as possible. All new features and bug fixes should have corresponding tests to ensure the long-term security and reliability of the code when possible. Run automated tests regularly and in as many environments as possible, to ensure they get run and that they cover all areas:
+
+- The first place they should run is on the machine that is making the changes. Running tests is most easily done within the IDE that is being used for editing, or as a script on the command line as the developer makes the changes.
+- The next place they should run is as part of the pull request commit/merge process.
+- The last place to run tests is as part of a Continuous Integration and Continuous Deployment (CI/CD) pipeline, or on your release candidate builds.
+
+The scope of the tests should increase at each step, with the last step providing full coverage for anything the other steps might miss.
+
+**Continuous use and maintenance**
+
+Test reliability is an important part of maintaining the effectiveness of the testing suite. Test failures should be assigned and investigated, with potential security issues getting high priority and getting updated within a prompt and predetermined timeframe. Ignoring test failures shouldn't be a common practice, but should require strong justification and approval. Test failures due to issues within the test suite itself should be treated the same as other failures, to prevent a lapse in coverage in which product issues could be missed.
+
+**Kinds of tests, especially unit tests**
+
+There are several types of automated tests, and while not all are applicable to all applications, a good test suite contains a selection of several different types. Code Based Test Cases such as unit tests are the most common and most integral, being applicable to all applications and intentionally covering as many code paths as possible for correctness. These tests should be small, quick, and not affect the state of the machine, so that the full suite of tests can be run quickly and often. If possible, run tests on many machines that have different hardware setups to catch problems that aren't reproducible on a single type of machine.
+
+**Visual Studio**
+
+Visual Studio Test Explorer natively supports many of the most popular C++ testing frameworks, and has options to install extensions for more frameworks. This flexibility is helpful for running a subset of tests covering the code you're working on, and makes it easy to debug test failures as they arise. Visual Studio also makes it easy to set up new test suites for existing projects, and provides helpful tools such as CodeLens to make it easier to manage these tests. For more information about writing, running, and managing C/C++ tests with Visual Studio, see [Write unit tests for C/C++ - Visual Studio (Windows)](/visualstudio/test/writing-unit-tests-for-c-cpp).
+
+**In Azure and GitHub CI/CD**
+
+Tests that do deeper verification and take longer to run, such as static analysis, component detection, and so on, are good candidates for pull request testing or continuous integration testing. Azure DevOps and GitHub [Actions](https://docs.github.com/en/actions) make it easy to run validations automatically and block code checkins if a validation fails. Automated enforcement helps ensure that all code being checked in is secure based on these more rigorous checks being run. Azure Pipelines and Azure DevOps Build Validation are described here:
+
+- [Git branch policies and settings - Azure Repos](/azure/devops/repos/git/branch-policies#build-validation)
+- [Defining the mergeability of pull requests | GitHub Docs](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests)
+
+## 2.3 Code-based, or static, analysis
+
+**Summary** Static code/binary analysis should be enabled by default, to be secure by default. Static analysis analyzes a program for required safety and security policies at the time it's being built, not at execution time when an exploit can occur on the customer's machine. Static analysis can analyze the program in source code form or in compiled executable form.
+
+**Recommendations** Microsoft recommends that you:
+
+- Enable static analysis for all C++ programs, for both the input source code (before compilation) and the executable binaries (after compilation). "Enable" might mean to run analysis during each build on the developer's machine, or as a separate build to inspect the code later or as a checkin requirement.
+- Incorporate static analysis into CI pipelines as a form of testing.
+- Static analysis by definition comes with false positives, and be prepared to incorporate that fact into your quality feedback loop. Be quick to enable all low-false-positive warnings up front. Then be proactive to gradually increase the number of rules for which your code base compiles warning-clean as you regularly add more rules that flag important bugs at the expense of gradually higher false positives (initially, before the code base has been cleaned for those rules too).
+- Always use the latest supported versions of Visual Studio, and set up your engineering environment to quickly consume the latest patch releases as soon as they become available, without delaying to the next development stage/cycle.
+
+**Key tools** Be aware of and use the following:
+
+- [Code analysis documentation - C++ and .NET](/visualstudio/code-quality/)
+- [`/analyze` - Visual C++ compiler](../build/reference/analyze-code-analysis.md)
+- [`/W4` and `/WX` - Visual C++ compiler](../build/reference/compiler-option-warning-level.md)
+- [Use the C++ Core Guidelines Checkers](using-the-cpp-core-guidelines-checkers.md)
+- [CodeQL | GitHub](https://codeql.github.com/)
+- [Binskim user guide | GitHub](https://github.com/microsoft/binskim/blob/main/docs/UserGuide.md)
+- See also (Windows only): [SAL annotations](../c-runtime-library/sal-annotations.md)
+
+Notes:
+
+- `/analyze` enables static analysis of C++ code at compile time to identify critical security and reliability code vulnerabilities. It should be enabled throughout a C++ program's entire development timeline. Start by enabling at least the "Microsoft Native Recommended" by default as a minimum baseline. Then consult the documentation for how to specify more rules, especially the C++ Core Guidelines rules, as required by your engineering policies. The source code Static Analysis capability is available in both the Visual C++ IDE and in the command-line Build Tools.
+- `/W4` and `/WX` should be enabled wherever possible, to ensure you compile your code cleanly at high warning levels (`W4`) and treat warnings as errors that must be fixed (`WX`). These options enable finding uninitialized data errors that other static analysis tools can't check, because the errors only become visible after the compiler back-end performs interprocedural analysis and inlining.
+- BinSkim binary analysis ensures that projects enable a broad range of security features. BinSkim generates PDBs and other outputs that make it easier to verify chain-of-custody and to respond efficiently to security issues. Microsoft recommends running the BinSkim tool to analyze all executable binaries (`.sys`, `.dll` or `.exe`) produced for or consumed by your programs. The BinSkim User Guide includes a list of supported security standards. Microsoft recommends that you fix all issues reported as "errors" by the BinSkim tool. Issues reported as "warnings" should be evaluated selectively, because resolving them can have performance implications or might not be necessary.
+
+**In Azure and GitHub CI/CD** Microsoft recommends always enabling source code and binary static analysis in release CI/CD scenarios. Run source analysis immediately on the local developer's machine, or at least for every commit or pull request, to catch source bugs as early as possible and minimize overall costs. Binary level bugs tend to be introduced more slowly, so it might be sufficient to run binary analysis in less frequent prerelease CI/CD scenarios (such as nightly or weekly builds).
+
+## 2.4 Review for hardcoded secrets
+
+**Summary**
+
+Don't hardcode secrets within software. You can find and remove secrets from the source code efficiently by using reliable tools that can scan your entire source code base. Once you find secrets, move them to a safe place following the guideline for secure storage and use of secrets.
+
+**Problem**
+
+"Secrets" means entities that establish identity and provide access to resources, or that are used to sign or encrypt sensitive data. Examples include passwords, storage keys, connection strings, and private keys. It's tempting to keep secrets in the software product so they can be readily obtained when needed by the software. However, these hardcoded secrets can lead to severe or catastrophic security incidents as they're easily discovered and can be used to compromise your service and data.
+
+**Prevention**
+
+Secrets hardcoded in source code (as plain text or encrypted blob) are a security vulnerability. Here are general guidelines on how to avoid secrets in the source code:
+
+- Use a precheckin tool to scan and catch potential hardcoded secrets in code prior submitting to source control.
+- Don't put clear text credentials in source code or configuration files.
+- Don't store clear text credentials in SharePoint, OneNote, file shares, and so on. Or share them via email, IM, and so on.
+- Don't encrypt a secret with an easily discoverable decryption key. For example, don't store a PFX file along with a file that contains its password.
+- Don't encrypt a secret with a weak decryption. For example, don't encrypt a PFX file with a weak or common password.
+- Avoid putting encrypted credentials in source code. Instead, use placeholders in your source, and let your deployment system replace them with secrets from approved stores.
+- Apply the same principles to secrets in environments such as testing, staging, and so on, as you do in production deployments. Adversaries often target nonproduction systems as they're less well managed, then use them to pivot into production.
+- Don't share secrets between deployments (for example, testing, staging, production).
+
+While not directly related to hardcoded secrets, also remember securing secrets for your test, development, and production:
+
+- Rotate your secrets periodically and whenever they might have been exposed. Having a demonstrated ability to rotate/redeploy secrets is evidence of a secure system. More notably, the absence of this capability is even stronger evidence of an inevitable vulnerability.
+- Don't give in to the common developer rationale that "my test credentials don't create risk." In practice, they nearly always do.
+- Consider moving away from secrets (for example, passwords, bearer keys) entirely in preference of RBAC/identity-driven solutions as a good engineering solution that can sidestep secret mismanagement entirely.
+
+**Detection**
+
+Legacy components of your product might contain hidden hardcoded secrets in their source code. Sometimes secrets from developers' desktop machines can creep into remote branch and merge into the release branch, leaking secrets unintentionally. To discover secrets that might be hiding in your source code, you can use tools that can scan your code for hardcoded secrets:
+
+- [Microsoft sarif-pattern-matcher tool](https://github.com/microsoft/sarif-pattern-matcher)
+
+**Remediation**
+
+When credentials are found in your source code, the immediate urgent need is to invalidate the exposed key and perform a risk analysis based on exposure. Even if your system needs to stay running, you can enable a secret manager for remediation using these steps:
+
+1. If remediation allows switching over to managed identities, or requires dropping in a secret manager such as Azure Key Vault (AKV), do that first. Then redeploy with the updated identity or key.
+1. Invalidate the exposed secret.
+1. Perform auditing/risk assessment of potential damage due to compromise.
+
+To safeguard cryptographic keys and other secrets used by cloud apps and services, use [Azure Key Vault](https://azure.microsoft.com/products/key-vault) with an appropriate access policy.
+
+If an exposure compromises certain customer data/PII, it might require other compliance/reporting requirements.
+
+Remove the now-invalidated secrets from your source code, and replace them with alternative methods that don't expose the secrets directly in your source code. Look for opportunities to eliminate secrets where possible by using tools like Azure AD. You can update your authentication methods to take advantage of managed identities via Azure Active Directory). Only use approved stores to store and manage secrets such as Azure Key Vault (AKV). For more information, see:
+
+- [Azure AD: Implementing autorotation using Azure Active Directory](https://eng.ms/docs/products/onecert-certificates-key-vault-and-dsms/key-vault-dsms/autorotationandecr/scenarios/aad)
+
+**Azure DevOps (AzDO)**
+
+AzDO users can scan their code through GitHub Advanced Security for Azure DevOps (GHAzDO). GHAzDO also allows users to prevent secret exposures by enabling Push Protection on their repositories, catching potential exposures before they're ever leaked. For more information on how to detect hardcoded secrets in code in Azure DevOps, see *Secret Scanning for GitHub Advanced Security for Azure DevOps* in each of the following links:
+
+- [GitHub advanced security for Azure DevOps](https://azure.microsoft.com/products/devops/github-advanced-security)
+- [Secret Scanning for GitHub Advanced Security for Azure DevOps](/azure/devops/repos/security/github-advanced-security-secret-scanning)
+- [Microsoft Defender for DevOps Preview](https://www.microsoft.com/security/business/cloud-security/microsoft-defender-devops)
+
+**In GitHub**
+
+Secret scanning is available on GitHub.com in two forms:
+
+- *Secret scanning alerts for partners.* Runs automatically on all public repositories. Any strings that match patterns that were provided by secret scanning partners are reported directly to the relevant partner.
+- *Secret scanning alerts for users.* You can enable and configure extra scanning for repositories owned by organizations that use GitHub Enterprise Cloud and have a license for GitHub Advanced Security. These tools also support private and internal repositories.
+
+GitHub provides known patterns of secrets for partners and users that can be configured to meet your needs. For more information, please see:
+
+- [Secret scanning patterns](https://docs.github.com/en/code-security/secret-scanning/secret-scanning-patterns#supported-secrets-for-user-alerts)
+- [About secret scanning in GitHub](https://docs.github.com/en/enterprise-cloud@latest/code-security/secret-scanning/about-secret-scanning)
+
+> [!NOTE]
+> GitHub Advanced Security for Azure DevOps brings the same secret scanning, dependency scanning and CodeQL code scanning solutions already available for GitHub users and natively integrates them into Azure DevOps to protect your Azure Repos and Pipelines.
+
+**Additional resources**
+
+- [Credential Scanning | Microsoft Code With Engineering Playbook](https://microsoft.github.io/code-with-engineering-playbook/CI-CD/dev-sec-ops/secrets-management/credential_scanning/).
+- [detect-secrets: Credential scanning tool | GitHub](https://microsoft.github.io/code-with-engineering-playbook/CI-CD/dev-sec-ops/secrets-management/recipes/detect-secrets/) - an aptly named module for detecting secrets within a code base.
+- [Running detect-secrets in Azure Pipelines](https://microsoft.github.io/code-with-engineering-playbook/CI-CD/dev-sec-ops/secrets-management/recipes/detect-secrets-ado/).
+- [Git-secrets | GitHub awslabs](https://github.com/awslabs/git-secrets) - prevents you from committing passwords and other sensitive information to a git repository.
+- [Secrets Management | Microsoft Code with Engineering Playbook](https://microsoft.github.io/code-with-engineering-playbook/CI-CD/dev-sec-ops/secrets-management/) - provides general guidelines on how secrets should be managed.
+
+## 2.5 Run with language- and OS-provided checks and protection
+
+**Summary**
+
+Binary hardening is done by applying compile-time security controls. These include mitigations that:
+- prevent exploitable vulnerabilities in code,
+- enable runtime detections that trigger security defenses on exploitation, and
+- enable data production and archiving to help limit the damage caused by security incidents.
+
+Binary consumers must opt into Windows security features to gain the full benefit of hardening.
+
+Microsoft provides a set of facilities specific to C++ projects to help developers write and ship safer and more secure code. C++ developers should also adhere to security standards common to languages that generate executable code. Microsoft maintains BinSkim, a public OSS binary checker that helps enforce use of many protections described in this section. For more information about BinSkim, see [Binskim user guide | GitHub](https://github.com/microsoft/binskim/blob/main/docs/UserGuide.md)
+
+Binary-level controls differ according to where they're applied in the engineering process. You should distinguish among compiler and linker options that: are strictly compile time, alter code generation with run-time overhead, and alter code generation to achieve compatibility with OS protections.
+
+Developer settings should prefer to enable as much static analysis as possible, enable production of private data to accelerate debugging, and so on. Release builds should be tuned to an appropriate combination of security, performance, and other code generation concerns. Release processes must be configured to properly generate and manage public vs. privately consumed build data (for example, public vs. private symbols).
+
+**Stay current: Always use up-to-date compilers and tools**
+
+Compile all code with current toolsets to benefit from up-to-date language support, static analysis, code generation and security controls. Because compilers impact every generated component, the potential for regression on tool update is relatively high. Using outdated compilers creates a particular risk for corrective action while responding to a security incident, because teams might not have enough time to upgrade compilers. Microsoft recommends that teams develop the facility to regularly refresh and test compiler updates.
+
+**Use secure development methods, language versions, frameworks/APIs**
+
+Code should utilize development methodologies, language versions, framework, APIs, and so on, that minimize risk by fostering safety and simplicity in C++, including:
+
+- See [C++ Core Guidelines' Guideline Support Library (GSL)](https://github.com/isocpp/CppCoreGuidelines) for guidance to write modern, safe, and consistent C++ code that follows best practices and avoids common pitfalls.
+- See [Microsoft GSL implementation](https://github.com/microsoft/GSL) for functions and types that the C++ Core Guidelines suggest you use.
+- Resource-safe C++ containers, C runtime library (CRT) memory overflow protections: Prefer [`std::vector`](../standard-library/vector-class.md) and [`std::string`](../standard-library/string.md), which are resource-safe. If you must use C data, use the [secure versions of CRT functions](../c-runtime-library/security-features-in-the-crt.md), which are designed to help prevent memory corruption due to buffer misuse and undefined language behaviors.
+- The [SafeInt library](../safeint/safeint-library.md) protects against integer overflow in mathematical and comparison operations.
+
+**Consume secure dependencies**
+
+Binaries shouldn't link to insecure libraries and dependencies. Development teams should track all external dependencies and resolve CVEs/identified security vulnerabilities in these components by updating to more secure versions when subject to those vulnerabilities.
+
+**Maximize code provenance guarantees and efficiency of security response**
+
+Compilation should enable strong code provenance guarantees to help detect and prevent introduction of backdoors and other malicious code. The resulting data, also critical to debugging and investigation, should be archived for all software releases to drive efficient security response if they're compromised. The following compiler switches generate information that is critical to a security response:
+
+- [`/ZH:SHA_SHA256` in Visual C++](../build/reference/zh.md) - Ensures that a cryptographically secure algorithm is used to generate all PDB source file hashes.
+- [`/Zi`, `/ZI` (Debug Information Format) in Visual C++](../build/reference/z7-zi-zi-debug-information-format.md) - In addition to publishing stripped symbols for collecting crash data and other public use scenarios, ensure that builds produce and archive private PDBs for all released binaries. Binary analysis tools require full symbols to verify whether many security mitigations were enabled at compile-time. Private symbols are critical in security response, and lower debugging and investigation costs when engineers are racing to assess and limit damage when an exploit happens.
+- [`/SOURCELINK` in Visual C++ Linker - Include Sourcelink file in PDB](../build/reference/sourcelink.md): Source link is a language- and source-control agnostic system providing source debugging for binaries. Source debugging greatly increases the efficiency the range of prerelease security validations and post-release incident response.
+
+**Enable compiler errors to prevent issues at code authoring time**
+
+Compilation should enable security-relevant compiler checks as breaking errors, for example:
+- [`/sdl` in Visual C++ - Enable additional security checks](https://aka.ms/AdditionalSecurityChecks) elevates many security-relevant warnings into errors and enables advanced secure code-generation features.
+- [BinSkim BA2007.EnableCriticalCompilerWarnings | GitHub](https://github.com/microsoft/binskim/blob/main/src/BinSkim.Rules/PERules/BA2007.EnableCriticalCompilerWarnings.cs) maintains a list of Microsoft-recommended C/C++ compiler warnings that should always be enabled and elevated to errors.
+
+**Mark binaries as compatible with OS runtime security mitigations**
+
+Compiler and linker settings should opt into code generation features that detect and mitigate malicious code execution, including:
+- Stack corruption prevention
+ - [`/SAFESEH` - Image has safe exception handlers](https://aka.ms/SafeExceptionHandlers) - Produces a table of the image's safe exception handlers for x86 binaries.
+ - [`/GS` - Buffer Security Check](https://aka.ms/BufferSecurityCheck) - Detects some buffer overruns that overwrite return addresses, exception handler addresses or certain types of parameters.
+- Position independent code execution
+ - [`/DYNAMICBASE` - Use Address Space Layout Randomization](https://aka.ms/ASLR) - Generates executable images that can be randomly rebased at load time.
+ - [`/HIGHENTROPVA` and `/LARGEADDRESSAWARE` - Support 64-bit ASLR, and Handle large addresses](https://aka.ms/HEVA) - Enables use of entire 64-bit address space for image rebasing.
+- Code flow integrity
+ - [`/guard:cf` - Enable Control Flow Guard](https://aka.ms/ControlFlowGuard) - Inserts runtime verifications for indirect call targets.
+ - [`/CETCOMPAT` - CET shadow stack compatible](https://aka.ms/CETShadowStack) - Marks an executable image as compatible with Microsoft's implementation of Intel's [Control-flow Enforcement Technology (CET)](https://www.intel.com/content/www/us/en/developer/articles/technical/technical-look-control-flow-enforcement-technology.html) Shadow Stack feature.
+ - [`/guard:ehcont` - Enable EH continuation metadata](../build/reference/guard-enable-eh-continuation-metadata.md) - Generates a list of safe relative virtual addresses (RVA) of all exception handling continuation targets.
+- Data execution prevention
+ - [`/NXCOMPAT` - Compatible with Data Execution Prevention](https://aka.ms/DataExecutionPrevention) - Marks a 32-bit executable image as compatible with the [Windows Data Execution Prevention (DEP)](https://support.microsoft.com/topic/what-is-data-execution-prevention-dep-60dabc2b-90db-45fc-9b18-512419135817) feature. 64-bit builds are compatible with DEP by default.)
+
+**Prevent sensitive information disclosure**
+
+Compiler settings should opt into sensitive information discovery prevention. In recent years, researchers have uncovered unintended information leakage that originates with hardware features such as speculative execution.
+
+At the software level, confidential data might be transmitted to attackers if unexpectedly leaked. Failure to zero-initialize buffers and other buffer misuse might leak private confidential data to attackers that call trusted API. This class of problem best handled by enabling extra static analysis and using secure resource containers as described previously.
+
+- [`/Qspectre` - Mitigate speculative execution side-channel attacks](https://aka.ms/SpectreMitigations) - Inserts barrier instructions that help prevent the disclosure of sensitive data produced by speculative execution. These mitigations should be enabled for code that stores sensitive data in memory and operates across a trust boundary. Microsoft always recommends measuring performance impact against appropriate benchmarks when enabling Spectre-mitigations due to the possibility of introducing runtime checks in performance-critical blocks or loops. These code paths can disable mitigations via the [`spectre(nomitigation)`](../cpp/spectre.md) `declspec` modifier. Projects that enable `/Qspectre` should also link to libraries that are also compiled with these mitigations, including the Microsoft runtime libraries.
+
+## 2.6 Black box test cases
+
+**Summary**
+
+Black box tests don't rely on knowing the tested component's inner workings. Black box tests are designed to test the end-to-end functionality of the features in the product at any layer or level. Black box tests can be functional tests, UI tests, performance tests, and integration tests. Black box tests are valuable for measuring general reliability and functional correctness, and ensuring that the product behaves as expected.
+
+**Relation to other sections**
+
+These types of requirement-based tests are useful for validating the assumptions made in the Threat Model and covering potential threats as brought up in that section. These tests are useful for testing the integration between separate components of the product, especially ones that are across trust boundaries as described in the threat model. Black box test cases are also useful for testing all kinds of edge cases for user input validation. Testing known edge cases and error cases are both useful. Fuzzing is also useful to test less obvious cases.
+
+**Automation and regression**
+
+Run these tests regularly, and compare the results to previous runs to catch breaking changes or performance regressions. Also, running these tests on many different machines and installation setups can help cover any issues that might arise from different architectures or setup changes.
+
+**Crash dumps**
+
+These tests help find issues with reliability, being able to test many different scenarios that might run into crashes, hangs, deadlocks, and so on. By collecting crash dumps as part of test failures, you can import the dumps directly into Visual Studio to further investigate what parts of the code are hitting these issues. If you run functional tests from within Visual Studio, you can easily replicate and debug failures by seeing exactly where inside the black box the test fails, and you can test fixes quickly.
+
+To get started with debugging tests, see [Debug unit tests with Test Explorer - Visual Studio (Windows)](/visualstudio/test/debug-unit-tests-with-test-explorer)
+
+**In Azure**
+
+Azure DevOps can also help manage and validate these tests with the use of Test Plans. These tests can be used to ensure approval with manual validation, and to run automated tests associated with product requirements. More information on Azure Test Plans and using them to run automated testing can be found here:
+- [What is Azure Test Plans? Manual, exploratory, and automated test tools. - Azure Test Plans](/azure/devops/test/overview)
+- [Run automated tests from test plans - Azure Test Plans](/azure/devops/test/run-automated-tests-from-test-hub)
+
+## 2.7 Code-based test cases
+
+**Summary**
+
+Code-based test cases are an integral part of maintaining the security and reliability of your product. These tests should be small and fast and shouldn't have an impact on each other so they can be run in parallel. Code-based tests are easy for developers to run locally on their development machine anytime they make changes to the code without worrying about slowing down their development cycle.
+
+**Types, and relation to other sections**
+
+Common types of code-based test cases include:
+- unit tests,
+- parameterized tests to cover functions with multiple input types,
+- component tests to keep each test component separate, and
+- mock testing to validate parts of the code that communicate with other services, without expanding the scope of the test to include those services themselves.
+
+These tests are based on the internal code that is written, whereas black box tests are based on the external functional requirements of the product.
+
+**Goal**
+
+Through these tests, the goal is to achieve a high level of test coverage over your code. You should actively track this coverage and where gaps exist. As you add more tests that exercise more code paths, the overall confidence in your code's security and reliability increases.
+
+**Visual Studio**
+
+The test explorer tools in Visual Studio make it easy to run these tests frequently and get feedback on pass/fail rates and failure locations quickly. Many of the test frameworks also support CodeLens features to see the test status at the location of the test itself, making adding and maintaining the suite of tests easier. The Test Explorer also makes managing these tests easy, allowing for test groups, custom test playlists, filtering, sorting, searching, and more.
+
+For more information, see:
+
+- [Unit testing fundamentals - Visual Studio (Windows)](/visualstudio/test/unit-test-basics) - an introduction and overview
+- [Run unit tests with Test Explorer - Visual Studio (Windows)](/visualstudio/test/run-unit-tests-with-test-explorer#group-and-filter-the-test-list) - a deeper look at what's available to help manage the potentially large set of unit tests with the Test Explorer
+
+Visual Studio also comes with tools for tracking the code coverage. These tools enable you to ensure that code changes you make are covered by existing tests, or to add new tests to cover new and untested code paths. The tools also show the code coverage percentage to ensure it's maintained above a target level for confidence in overall code quality.
+
+For information about these tools, see [Code coverage testing - Visual Studio (Windows)](/visualstudio/test/using-code-coverage-to-determine-how-much-code-is-being-tested)
+
+**In Azure**
+
+Azure DevOps can also help in tracking code coverage results for the whole product as part of the build pipeline process. For more information, see [Review code coverage - Azure Pipelines](/azure/devops/pipelines/test/review-code-coverage-results).
+
+## 2.8 Historical test cases
+
+**Summary**
+
+Historical test cases, also known as regression test cases, prevent old issues from resurfacing again and increase the overall test coverage of the product. You should ensure that when a bug is fixed the project also adds a corresponding test case. Over time, as fixes are made, the overall robustness of the testing suite will keep improving, giving better assurances of reliability and security.
+
+**Key qualities, and relation to other sections**
+
+Since they test for bug regressions, these tests should be quick and easy to run, so they can run alongside the [Code Based Test Cases](#27-code-based-test-cases) and contribute to the overall code coverage of the product. Along with this, using real examples from customers to inspire new test cases is a great way to improve coverage and quality of tests.
+
+**Visual Studio**
+
+Visual Studio lets you easily add tests to the suite while making the changes to fix the bug, and quickly run the tests and code coverage to ensure all new cases get considered. Referencing the bug ID from your issue tracking system in your code where you write the test is a good way to connect regression tests to the corresponding issues. Prefer to use Azure Boards and test plans together with Visual Studio:
+- to associate tests, test cases, and issues; and
+- to track of all aspects of an issue and its corresponding tests.
+
+For more information, see:
+- [Associate automated tests with test cases - Azure Test Plans](/azure/devops/test/associate-automated-test-with-test-case)
+- [Link work items to other objects - Azure DevOps](/azure/devops/organizations/notifications/add-links-to-work-items)
+
+Eventually, integrating these tests into the unit testing area that is supposed to cover the code section helps keep the test suite organized and easier to manage. You can use the Test Explorer's test grouping to effectively track the tests that belong together. For more information, see [Run unit tests with Test Explorer - Visual Studio (Windows)](/visualstudio/test/run-unit-tests-with-test-explorer#group-and-filter-the-test-list)
+
+## 2.9 Fuzzing
+
+**Summary**
+Fuzzing (also known as fuzz testing) is an automated software testing technique that involves providing invalid, unexpected, or random data as input to a program. The program is then monitored for exceptions such as crashes, failing built-in or compiler injected code assertions and potential memory leaks.
+
+**Guidance**
+
+Use fuzzing on all software that might process untrusted inputs that an attacker could control. If you're building a new application and its associated test suite, include fuzzing for key modules as early as possible. Running fuzzing for the first time on a piece of software nearly always uncovers actual vulnerabilities that were previously unknown. Once you start fuzzing, never stop.
+
+**Relation to other sections**
+
+When fuzzing reports a failure, it always naturally provides a reproducible test case that demonstrates the bug. This test case can be reproduced, resolved, and then added to the Historical Test Cases.
+
+When using both sanitizers such as [Address Sanitizer (ASan)](../sanitizers/asan.md) and fuzzing:
+- First run your normal tests with sanitizers enabled to see if there are issues, then once the code is sanitizer-clean start fuzzing.
+- For C or C++, there are compilers that automate injection of runtime assertions and meta-data that enable ASan. When compiled for ASan, the resulting binaries link with a runtime library that can precisely diagnose [15+ categories of memory safety errors](../sanitizers/asan.md#error-types) with zero false positives. For C or C++ when you have source, use [LibFuzzer](https://www.llvm.org/docs/LibFuzzer.html), which requires ASan to be enabled first.
+- For libraries written in Java, C#, Python, Rust, and so on, use the [AFL++ framework](https://aflplus.plus/).
+
+**Key qualities**
+
+- Fuzzing finds vulnerabilities often missed by static program analysis, exhaustive feature testing and manual code inspection.
+- Fuzzing is an effective way to find security and reliability bugs in software, so much so that the [Microsoft Security Development Lifecycle](https://www.microsoft.com/securityengineering/sdl/) requires fuzzing at every untrusted interface of every product (see also Threat Modeling).
+- Always use fuzzing for software that might process untrusted inputs.
+- Fuzzing is effective for standalone applications with large data parsers.
+
+**Azure and GitHub CI/CD**
+
+Modify your build(s) to support continuous creation of executables that use LibFuzzer or AFL++. You can add extra computing resources required for fuzzing at services like OSS-Fuzz.
+
+## 2.10 Web Application Scanning
+
+**Summary**
+
+Within the scope of Microsoft Visual C++ on Windows, Microsoft recommends:
+
+- Prefer TypeScript, JavaScript, and ASP.NET for web applications.
+- Don't write web extensions in C++. Microsoft has deprecated ActiveX.
+- When code is compiled to Emscripten/WASM, it's no longer C++ and other tools apply.
+- Microsoft provides [RESTler, a stateful REST API fuzzer](https://github.com/microsoft/restler-fuzzer).
+
+**Overview and key qualities**
+
+A web application scanner explores a web application by crawling through its web pages and examines it for security vulnerabilities. This crawl involves the automatic generation of malicious inputs and evaluation of the application's responses. Critically, web application scanning must cover/support:
+
+- Catalogs all web apps in your network, including new and unknown ones, and scales from a handful of apps to thousands.
+- Deep scanning for software versions, SOAP and REST API services and APIs used by mobile devices.
+- Insertion of security primitives into application development and deployment in DevOps environments. These primitives work with the crawler.
+- Malware detection.
+
+## 2.11 Check Included Software Components
+
+**Summary**
+
+Handle your C++ code the same as code written in other programming languages, and apply any Software Composition Analysis (SCA) and Origin Analysis (OA) tooling adopted by your company to your C++ code. Workflows and security scanning should be designed as part of CI/CD (continuous integration and continuous delivery) systems.
+
+**Upstream defense**
+
+To mitigate the risk of attacks on upstream dependencies, third party sources/components should be stored on an enterprise-controlled asset, against which SCA and OA tools are run.
+- Tools should scan and alert when vulnerabilities are identified (including public databases) such as: [Home | CVE](https://www.cve.org/)
+- Run static analysis on all software components included in your application/repo to identify vulnerable code patterns.
+
+**Dependency defense**
+
+Perform and maintain an audit of dependencies to validate that all such occurrences are accounted for and covered by your SCA and OA tools.
+- Components should be regularly audited and updated to the latest verified versions.
+- Package feed dependencies.
+- SCA/OA tools cover and audit all package dependencies that come from a single feed.
+
+**SBOM**
+
+Produce an SBOM (software bill of materials) with your product listing all dependencies such as:
+- origin (for example, URL (Uniform Resource Locator))
+- version
+- consistency (for example, SHA-256 source hash), and other means for validating consistency such as deterministic builds.
+- Require and audit SBOM files in software dependencies or produced as part of a build including OSS (open-source software).
+- Microsoft is standardizing on and recommends [SPDX (Software Package Data Exchange) version 2.2 or later | Linux Foundation](https://spdx.dev/specifications/) as the SBOM document format.
+- Build determinism can be used to independently produce bit-wise identical binaries and provide independent verifications of integrity:
+ - First-party or third-party attestation of reproducibility
+ - Other techniques such as binary signing via a trusted certificate source can also provide some assurances of binary integrity.
+
+**Additional resources**
+
+Microsoft solutions include the following guidance and products:
+- [Microsoft Supply Chain Platform | Microsoft](https://www.microsoft.com/microsoft-cloud/solutions/microsoft-supply-chain-platform)
+- [Secure your software supply chain | GitHub Security](https://github.com/features/security/software-supply-chain)
+- [vcpkg](/vcpkg/) - vcpkg private registries allow redirection of OSS acquisition to Enterprise-controlled resources for acquiring sources for a dependency, to minimize risk of upstream or over-the-wire attacks.
diff --git a/docs/code-quality/c26132.md b/docs/code-quality/c26132.md
new file mode 100644
index 0000000000..390903a605
--- /dev/null
+++ b/docs/code-quality/c26132.md
@@ -0,0 +1,73 @@
+---
+title: Warning C26132
+description: Documentation on static analysis warning C26132
+author: Rastaban
+ms.author: philc
+ms.service: visual-cpp
+ms.topic: article
+ms.date: 02/11/2025
+---
+# Warning C26132
+
+> Variable '*variable name*' should be protected by '*lock 1*', but '*lock 2*' is held instead. Possible annotation mismatch.
+
+The analyzer issues Warning C26132 when it detects that a lock, which is annotated to protect a value, isn't held while accessing the value. However, a related lock is held. The code may be thread-safe, so you might need to update the annotations.
+
+This diagnostic usually doesn't indicate a bug in the code, but rather a mismatch between the annotations and the actual locking behavior. If so, the diagnostic should be resolved as there may be other static analysis issues that aren't being reported due to the inconsistent annotations.
+
+## Examples
+
+In the following example, C26132 is emitted when `data` is used.
+
+ The annotation specifies that `customLock01` should protect the variable `data`, but `CustomLockAcquire` is responsible for acquiring the related lock `customLock01->cs`.
+
+```cpp
+#include
+struct CustomLock
+{
+ int cs; // "Critical Section" lock
+};
+
+_Acquires_exclusive_lock_(criticalSection->cs) // notice the `->` indirection
+void CustomLockAcquire(CustomLock* criticalSection);
+
+_Releases_lock_(criticalSection->cs) // notice the `->` indirection
+void CustomLockRelease(CustomLock* criticalSection);
+
+// global lock
+CustomLock customLock01;
+
+void Initialize(_Guarded_by_(customLock01) int* data)
+{
+ CustomLockAcquire(&customLock01);
+ *data = 1; // C26132
+ CustomLockRelease(&customLock01);
+}
+```
+
+In this example, the `Initialize` function is thread-safe and behaves as designed, but that design isn't correctly reflected in the concurrency SAL annotations. Fix by adjusting the annotations on the custom locking functions to use `criticalSection` rather than `criticalSection->cs`. The warning could also be fixed by changing the `_Guarded_by_` annotation from `customLock01` to `customLock01.cs`.
+
+```cpp
+#include
+struct CustomLock
+{
+ int cs; // "Critical Section" lock
+};
+
+_Acquires_exclusive_lock_(criticalSection)
+void CustomLockAcquire(CustomLock* criticalSection);
+
+_Releases_lock_(criticalSection)
+void CustomLockRelease(CustomLock* criticalSection);
+
+// global lock
+CustomLock customLock01;
+
+void Initialize(_Guarded_by_(customLock01) int* data)
+{
+ CustomLockAcquire(&customLock01);
+ *data = 1;
+ CustomLockRelease(&customLock01);
+}
+```
+
diff --git a/docs/code-quality/c26133.md b/docs/code-quality/c26133.md
new file mode 100644
index 0000000000..0074674044
--- /dev/null
+++ b/docs/code-quality/c26133.md
@@ -0,0 +1,76 @@
+---
+title: Warning C26133
+description: Documentation on static analysis warning C26133
+author: Rastaban
+ms.author: philc
+ms.service: visual-cpp
+ms.topic: article
+ms.date: 02/19/2025
+---
+# Warning C26133
+
+> Caller failing to hold lock '*lock 1*' before calling function '*function name*', but '*lock 2*' is held instead. Possible annotation mismatch.
+
+Warning C26133 is issued when the analyzer detects that the lock required to call a function isn't held when the function is called. However, another lock that appears to be related is held. It's possible the code is thread-safe, and the annotations need to be updated.
+
+This diagnostic usually doesn't indicate a bug in the code, but rather a mismatch between the annotations and the actual locking behavior. If so, the diagnostic should be resolved as there may be other static analysis issues that aren't being reported due to the inconsistent annotations.
+
+## Examples
+
+In the following example, C26133 is emitted when `DoTaskWithCustomLock` is called.
+
+> warning C26133: Caller failing to hold lock 'customLock01' before calling function 'DoTaskWithCustomLock', but '(&customLock01)->cs' is held instead. Possible annotation mismatch.
+
+```cpp
+#include
+
+struct CustomLock
+{
+ int cs; // "Critical Section"
+};
+
+_Acquires_exclusive_lock_(criticalSection->cs) // notice the `->` indirection
+void CustomLockAcquire(CustomLock* criticalSection);
+
+_Releases_lock_(criticalSection->cs) // notice the `->` indirection
+void CustomLockRelease(CustomLock* criticalSection);
+
+CustomLock customLock01;
+
+_Requires_lock_held_(customLock01) void DoTaskWithCustomLock();
+
+void DoTask()
+{
+ CustomLockAcquire(&customLock01);
+ DoTaskWithCustomLock(); // C26133
+ CustomLockRelease(&customLock01);
+}
+```
+
+In this example, the `DoTask` function is thread-safe and behaves as designed, but that design isn't correctly reflected in the concurrency SAL annotations. Fix by adjusting the annotations on the custom locking functions to use `criticalSection` rather than `criticalSection->cs`. The warning could also be fixed by changing the `_Requires_lock_held_` annotation from `customLock01` to `customLock01.cs`.
+
+```cpp
+#include
+
+struct CustomLock
+{
+ int cs; // "Critical Section"
+};
+
+_Acquires_exclusive_lock_(criticalSection)
+void CustomLockAcquire(CustomLock* criticalSection);
+
+_Releases_lock_(criticalSection)
+void CustomLockRelease(CustomLock* criticalSection);
+
+CustomLock customLock01;
+
+_Requires_lock_held_(customLock01) void DoTaskWithCustomLock();
+
+void DoTask()
+{
+ CustomLockAcquire(&customLock01);
+ DoTaskWithCustomLock();
+ CustomLockRelease(&customLock01);
+}
+```
\ No newline at end of file
diff --git a/docs/code-quality/c26135.md b/docs/code-quality/c26135.md
index bbd4c04054..96db147d01 100644
--- a/docs/code-quality/c26135.md
+++ b/docs/code-quality/c26135.md
@@ -25,14 +25,14 @@ typedef struct _DATA
void MyEnter(DATA* p)
{
// Warning C26135:
- // Missing side effect annotation _Acquires_lock_(&p->cs)
+ // Missing side effect annotation _Acquires_lock_(p->cs)
EnterCriticalSection(&p->cs);
}
void MyLeave(DATA* p)
{
// warning C26135:
- // Missing side effect annotation _Releases_lock_(&p->cs)
+ // Missing side effect annotation _Releases_lock_(p->cs)
LeaveCriticalSection(&p->cs);
}
```
diff --git a/docs/code-quality/c26401.md b/docs/code-quality/c26401.md
index ef45225be5..023338c378 100644
--- a/docs/code-quality/c26401.md
+++ b/docs/code-quality/c26401.md
@@ -63,7 +63,7 @@ public:
ref_count_--;
if (ref_count_ == 0)
{
- [[gsl::suppress(i.11)]]
+ [[gsl::suppress("i.11")]]
delete this;
}
}
diff --git a/docs/code-quality/c26409.md b/docs/code-quality/c26409.md
index 8939a08776..a0dc4a4f3d 100644
--- a/docs/code-quality/c26409.md
+++ b/docs/code-quality/c26409.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about CppCoreCheck rule C26409: avoid explicit new and delete."
title: Warning C26409
+description: "Learn more about CppCoreCheck rule C26409: avoid explicit new and delete."
ms.date: 12/14/2020
f1_keywords: ["C26409", "NO_NEW_DELETE"]
helpviewer_keywords: ["C26409"]
-ms.assetid: a3b3a229-d566-4be3-bd28-2876ccc8dc37
---
# Warning C26409
@@ -13,7 +12,7 @@ ms.assetid: a3b3a229-d566-4be3-bd28-2876ccc8dc37
Even if code is clean of calls to `malloc` and `free`, we still suggest that you consider better options than explicit use of operators [`new` and `delete`](../cpp/new-and-delete-operators.md).
**C++ Core Guidelines**:\
-[R.11: Avoid calling new and delete explicitly](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly)
+[R.11: Avoid calling `new` and `delete` explicitly](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly)
The ultimate fix is to use smart pointers and appropriate factory functions, such as [`std::make_unique`](../standard-library/memory-functions.md#make_unique).
@@ -49,7 +48,7 @@ public:
ref_count_--;
if (ref_count_ == 0)
{
- [[gsl::suppress(i.11)]]
+ [[gsl::suppress("i.11")]]
delete this;
}
}
diff --git a/docs/code-quality/c26414.md b/docs/code-quality/c26414.md
index 471b69d1d9..d33427adcb 100644
--- a/docs/code-quality/c26414.md
+++ b/docs/code-quality/c26414.md
@@ -4,14 +4,13 @@ description: "Reference for Visual Studio C++ Core Guidelines code analysis warn
ms.date: 01/29/2020
f1_keywords: ["C26414", "RESET_LOCAL_SMART_PTR"]
helpviewer_keywords: ["C26414"]
-ms.assetid: dd875d0c-6752-4491-a533-3e8831795fbc
---
# Warning C26414
> "Move, copy, reassign or reset a local smart pointer."
**C++ Core Guidelines**:\
-[R.5: Prefer scoped objects, don't heap-allocate unnecessarily](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-scoped)
+[R.5: Prefer scoped objects, don't heap-allocate unnecessarily](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r5-prefer-scoped-objects-dont-heap-allocate-unnecessarily)
Smart pointers are convenient for dynamic resource management, but they're not always necessary. For example, it may be easier and more efficient to manage a local dynamic buffer by using a standard container. You may not need dynamic allocation at all for single objects, for example, if they never outlive their creator function. They can be replaced with local variables. Smart pointers become handy when a scenario requires a change of ownership. For example, when you reassign a dynamic resource multiple times, or in multiple paths. They're also useful for resources obtained from external code. And, when smart pointers are used to extend the lifetime of a resource.
diff --git a/docs/code-quality/c26430.md b/docs/code-quality/c26430.md
index ca0a31cf88..230352b2e9 100644
--- a/docs/code-quality/c26430.md
+++ b/docs/code-quality/c26430.md
@@ -27,8 +27,6 @@ A variable is marked as checked for null when it's used in the following context
- in non-bitwise logical operations;
- in comparison operations where one operand is a constant expression that evaluates to zero.
-The rule doesn't have full data flow tracking. It can produce incorrect results in cases where indirect checks are used (such as when an intermediate variable holds a null value and is later used in a comparison).
-
Implicit null checks are assumed when a pointer value is assigned from:
- an allocation performed with throwing `operator new`;
@@ -67,3 +65,36 @@ void merge_states(gsl::not_null left, gsl::not_null `If you define or delete any default operation in the type 'type-name', define or delete them all (c.21).`
**C++ Core Guidelines**:\
-[C.21: If you define or =delete any default operation, define or =delete them all](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all)
+[C.21: If you define or `=delete` any copy, move, or destructor function, define or `=delete` them all](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c21-if-you-define-or-delete-any-copy-move-or-destructor-function-define-or-delete-them-all)
Special operations such as constructors are assumed to alter the behavior of types so they rely more on language mechanisms to automatically enforce specific scenarios. The canonical example is resource management. If you explicitly define, default, or delete any of these special operations, it signals you want to avoid any special handling of a type. It's inconsistent to leave the other operations unspecified, that is, implicitly defined as deleted by the compiler.
diff --git a/docs/code-quality/c26434.md b/docs/code-quality/c26434.md
index 7db222af1a..0bdfe9d173 100644
--- a/docs/code-quality/c26434.md
+++ b/docs/code-quality/c26434.md
@@ -4,7 +4,6 @@ description: "Microsoft C++ Code Analysis warning C26434 for the C++ Core Guidel
ms.date: 08/21/2020
f1_keywords: ["C26434", "DONT_HIDE_METHODS"]
helpviewer_keywords: ["C26434"]
-ms.assetid: 7f66477f-da66-444a-a6e3-44513d7d7e31
---
# Warning C26434
@@ -44,5 +43,4 @@ struct Derived : Base
void not_virtual() noexcept {} // C26434, hides a non-virtual function
virtual void not_virtual(int i) noexcept {} // C26434, and parameters ignored
};
-
```
diff --git a/docs/code-quality/c26435.md b/docs/code-quality/c26435.md
index f66dacda9a..ab4ec78c93 100644
--- a/docs/code-quality/c26435.md
+++ b/docs/code-quality/c26435.md
@@ -7,7 +7,7 @@ helpviewer_keywords: ["C26435"]
---
# Warning C26435
-> Function '*symbol*' should specify exactly one of 'virtual', 'override', or 'final' (c.128)
+> The virtual function '*symbol*' should specify exactly one of 'virtual', 'override', or 'final' (c.128)
## C++ Core Guidelines
@@ -41,6 +41,9 @@ public:
void Draw() override final { // C26435, only 'final' is necessary.
//...
}
+ virtual void DrawCircumference() final { // C26435, should be neither 'virtual' nor 'final'.
+ //...
+ }
};
```
diff --git a/docs/code-quality/c26437.md b/docs/code-quality/c26437.md
index f617e904ca..2f96db0776 100644
--- a/docs/code-quality/c26437.md
+++ b/docs/code-quality/c26437.md
@@ -1,19 +1,18 @@
---
-description: "Learn more about: Warning C26437 DONT_SLICE"
title: Warning C26437
-ms.date: 10/07/2019
+description: "Learn more about: Warning C26437 DONT_SLICE"
+ms.date: 05/17/2023
f1_keywords: ["C26437", "DONT_SLICE"]
helpviewer_keywords: ["C26437"]
-ms.assetid: ed2f55bc-a6d8-4cc4-8069-5c96e581a96a
---
# Warning C26437
> Do not slice.
**C++ Core Guidelines**:
-[ES.63: Don't slice](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-slice)
+[ES.63: Don't slice](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es63-dont-slice)
-[Slicing](https://en.wikipedia.org/wiki/Object_slicing) is allowed by the compiler and can be viewed as a special case of a dangerous implicit cast. Even if it's done intentionally and doesn't lead to immediate issues, it's still highly discouraged. It makes code unmaintainable, by forcing extra requirements on related data types. It's especially true if types are polymorphic or involve resource management.
+The language allows [slicing](https://en.wikipedia.org/wiki/Object_slicing) and can be viewed as a special case of a dangerous implicit cast. Even if it's done intentionally and doesn't lead to immediate issues, it's still highly discouraged. It makes code harder to change, by forcing extra requirements on related data types. It's especially true if types are polymorphic or involve resource management.
## Remarks
@@ -23,10 +22,9 @@ The rule also flags cases where an assignment doesn't involve real data slicing
## Example
-Slicing points to outdated interface:
+In the next code example, we read `id_ex`, but the caller of the function will only get a slice of the object:
```cpp
-interface
struct id {
int value;
};
@@ -45,7 +43,7 @@ bool read_id(stream &s, id &v) {
}
```
-Slicing points to outdated interface - corrected:
+To fix the issue, update the function to use the correct types:
```cpp
// ...
diff --git a/docs/code-quality/c26439.md b/docs/code-quality/c26439.md
index 8bfaa4bb5a..85e7499a1e 100644
--- a/docs/code-quality/c26439.md
+++ b/docs/code-quality/c26439.md
@@ -1,41 +1,40 @@
---
title: Warning C26439
-ms.date: 11/15/2017
+description: CppCoreCheck rule C26439 that enforces C++ Core Guidelines F.6
+ms.date: 05/17/2023
f1_keywords: ["C26439", "SPECIAL_NOEXCEPT"]
helpviewer_keywords: ["C26439"]
-ms.assetid: 9df2a1b0-ea94-4884-9d28-c1522ec33a1b
-description: CppCoreCheck rule C26439 that enforces C++ Core Guidelines F.6
---
# Warning C26439
> This kind of function may not throw. Declare it 'noexcept'.
-[**C++ Core Guidelines** F.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#f6-if-your-function-may-not-throw-declare-it-noexcept): If your function may not throw, declare it noexcept
+[F.6: If your function must not throw, declare it `noexcept`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f6-if-your-function-must-not-throw-declare-it-noexcept)
+
+Some operations should never throw exceptions. Their implementations should be reliable and should handle possible errors conditions gracefully. They shouldn't use exceptions to indicate failure. This rule flags cases where such operations aren't explicitly marked as `noexcept`, which means that they may throw exceptions and consumers can't make assumptions about its reliability.
+
+It's important for these functions to be reliable as they're often used as building blocks to implement functions with [exception safety guarantees](https://en.cppreference.com/w/cpp/language/exceptions). A move constructor that throws will force Standard Template Library (STL) containers to fall back to copy operations, reducing runtime performance.
-Some kinds of operations should never cause exceptions. Their implementations should be reliable and should handle possible errors conditions gracefully. They should never use exceptions to indicate failure. This rule flags cases where such operations aren't explicitly marked as `noexcept`, which means that they may throw exceptions and can't convey assumptions about their reliability.
+Code analysis name: `SPECIAL_NOEXCEPT`
## Remarks
- Special kinds of operations:
- destructors;
- - default constructors;
- move constructors and move assignment operators;
- standard functions with move semantics: `std::move` and `std::swap`.
-- Non-standard and outdated specifiers like `throw()` or `declspec(nothrow)` aren't equivalent to `noexcept`.
+- Nonstandard and outdated specifiers like `throw()` or `declspec(nothrow)` aren't equivalent to `noexcept`.
- Explicit specifiers `noexcept(false)` and `noexcept(true)` are respected appropriately.
-- The warning may still appear for operations that are marked as `constexpr`. This check may change in future releases.
-
## Example
-All functions except the destructor will warn because they're missing noexcept.
+The tool warns on all functions except the destructor because they're missing `noexcept`.
```cpp
struct S
{
- S() {} // C26455, Default constructor may not throw. Declare it 'noexcept'
~S() {}
S(S&& s) {/*impl*/} // C26439, This kind of function may not throw. Declare it 'noexcept' (f.6)
@@ -46,12 +45,11 @@ struct S
};
```
-With noexcept decorating the same structure, all warnings are removed.
+With `noexcept` decorating the same structure, all warnings are removed.
```cpp
struct S
{
- S() noexcept {}
~S() {}
S(S&& s) noexcept {/*impl*/}
@@ -61,3 +59,8 @@ struct S
S& operator=(const S& s) noexcept {/*impl*/}
};
```
+
+## See also
+
+[C26455](c26455.md)\
+[F.6: If your function must not throw, declare it `noexcept`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f6-if-your-function-must-not-throw-declare-it-noexcept)
diff --git a/docs/code-quality/c26441.md b/docs/code-quality/c26441.md
index 0b49ad9810..c2f5dc91b8 100644
--- a/docs/code-quality/c26441.md
+++ b/docs/code-quality/c26441.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26441 NO_UNNAMED_GUARDS"
title: Warning C26441
-ms.date: 2/7/2023
+description: "Learn more about: Warning C26441 NO_UNNAMED_GUARDS."
+ms.date: 5/11/2023
f1_keywords: ["C26441", "NO_UNNAMED_GUARDS"]
helpviewer_keywords: ["C26441"]
---
@@ -11,7 +11,7 @@ helpviewer_keywords: ["C26441"]
## C++ Core Guidelines
-[CP.44](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cp44-remember-to-name-your-lock_guards-and-unique_locks): Remember to name your `lock_guard`s and `unique_lock`s
+[CP.44: Remember to name your `lock_guard`s and `unique_lock`s](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cp44-remember-to-name-your-lock_guards-and-unique_locks)
## Remarks
@@ -19,13 +19,23 @@ The standard library provides locks to help control concurrent access to resourc
This diagnostic only analyzes the standard lock types `std::scoped_lock`, `std::unique_lock`, and `std::lock_guard`. Warning [C26444](c26444.md) covers other unnamed RAII types.
-The analyzer only analyzes simple calls to constructors. More complex initializer expressions may lead to inaccurate results in the form of missed warnings. Locks passed as arguments to function calls or returned as results of function calls are ignored because the analysis tool is unable to determine if those locks are deliberately trying to protect that function call or if they should be extended. To provide similar protection for types returned by a function call, annotate them with `[[nodiscard]]`. The analyzer ignores locks created as temporaries but assigned to named references to extend their lifetime.
+The analyzer only analyzes simple calls to constructors. More complex initializer expressions may lead to inaccurate results in the form of missed warnings. The analyzer ignores locks passed as arguments to function calls or returned from function calls. It's unable to determine if those locks are deliberately trying to protect that function call or if their [lifetime should be extended](https://abseil.io/tips/107). To provide similar protection for types returned by a function call, annotate them with `[[nodiscard]]`. You can also annotate constructors with `[[nodiscard]]` to avoid unnamed objects of that type:
+
+```cpp
+struct X { [[nodiscard]] X(); };
+
+void f() {
+ X{}; // warning C4834
+}
+```
+
+ The analyzer ignores locks created as temporaries but assigned to named references to extend their lifetime.
Code analysis name: `NO_UNNAMED_GUARDS`
## Example
-In this example the name of the scoped lock is missing.
+In this example, the name of the scoped lock is missing.
```cpp
void print_diagnostic(std::string_view text)
diff --git a/docs/code-quality/c26444.md b/docs/code-quality/c26444.md
index bad8c2812a..cc020442fe 100644
--- a/docs/code-quality/c26444.md
+++ b/docs/code-quality/c26444.md
@@ -1,53 +1,49 @@
---
-description: "Learn more about: Warning C26444 NO_UNNAMED_RAII_OBJECTS"
title: Warning C26444
-ms.date: 01/18/2017
+description: "Learn more about: Warning C26444 NO_UNNAMED_RAII_OBJECTS."
+ms.date: 05/11/2023
f1_keywords: ["C26444", "NO_UNNAMED_RAII_OBJECTS"]
helpviewer_keywords: ["C26444"]
---
# Warning C26444
-> Avoid unnamed objects with custom construction and destruction.
+> Don't try to declare a local variable with no name (es.84).
## C++ Core Guidelines
-[ES.84: Don't (try to) declare a local variable with no name](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-noname)
+[ES.84: Don't try to declare a local variable with no name](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es84-dont-try-to-declare-a-local-variable-with-no-name)
-Unnamed (that is, temporary) objects with non-trivial behavior may point to either (a) inefficient code that allocates and immediately throws away resources or (b) to the code that unintentionally ignores non-primitive data. Sometimes it may also indicate plainly wrong declaration.
+An unnamed variable declaration creates a temporary object that is discarded at the end of the statement. Such temporary objects with nontrivial behavior may point to either inefficient code that allocates and immediately throws away resources or to the code that unintentionally ignores nonprimitive data. Sometimes it may also indicate plainly wrong declaration.
-## Notes
+## Remarks
-- This rule detects types with non-deleted destructors. Keep in mind that destructors can be compiler generated.
-- The warning can flag code that isn't compiler generated and that invokes either a non-default constructor of a RAII type or a function that returns an object of such type. This warning helps to detect ignored call results in addition to wrong declarations.
+- This rule detects types with a hand-written destructor or a compiler-generated destructor that transitively calls a hand-written destructor.
+- This rule can flag code that invokes a nontrivial constructor of an RAII type.
- The logic skips temporaries if they're used in higher-level expressions. One example is temporaries that are passed as arguments or used to invoke a function.
-- The standard library implementation may have different versions of destruction logic for some types (for example, containers). This can produce noisy warnings on debug builds because it's customary to ignore iterators returned from calls like [`std::vector::insert`](../standard-library/vector-class.md#insert). While such warnings aren't actionable in most cases, they're legitimate in pointing to the place where some non-obvious work is done in temporary objects.
Code analysis name: `NO_UNNAMED_RAII_OBJECTS`
-## Example: Ignored call result
+## Examples
```cpp
-std::string ToTraceMessage(State &state);
-void SaveState(State &state)
+struct A { A(int i); ~A(); };
+void Foo()
{
- // ...
- ToTraceMessage(state); // C26444, should we do something with the result of this call?
+ A{42}; // warning C26444: Don't try to declare a local variable with no name (es.84).
}
+```
-Example: Ignored call result - fixed.
-std::cerr << ToTraceMessage(state);
+To fix the issue, convert the temporary object to a local.
-Example: Unexpected lifetime.
-void SplitCache()
+```cpp
+struct A { A(int i); ~A(); };
+void Foo()
{
- gsl::finally([] { RestoreCache(); }); // C26444, RestoreCache is invoked immediately!
- //...
+ A guard{42}; // OK.
}
-
-Example: Unexpected lifetime - fixed.
-const auto _ = gsl::finally([] { RestoreCache(); });
```
## See also
-[ES.84: Don't (try to) declare a local variable with no name](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md)
+[C26441](C26441.md)\
+[ES.84: Don't try to declare a local variable with no name](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es84-dont-try-to-declare-a-local-variable-with-no-name)
diff --git a/docs/code-quality/c26449.md b/docs/code-quality/c26449.md
index 4dce008f58..85de9ef0c3 100644
--- a/docs/code-quality/c26449.md
+++ b/docs/code-quality/c26449.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26449 NO_SPAN_FROM_TEMPORARY"
title: Warning C26449
-ms.date: 03/22/2018
+description: "Learn more about: Warning C26449 NO_SPAN_FROM_TEMPORARY."
+ms.date: 05/11/2023
f1_keywords: ["C26449", "NO_SPAN_FROM_TEMPORARY"]
helpviewer_keywords: ["C26449"]
---
@@ -9,9 +9,11 @@ helpviewer_keywords: ["C26449"]
> `gsl::span` or `std::string_view` created from a temporary will be invalid when the temporary is invalidated (gsl.view)
-C++ Core Guidelines: [GSL.view: Views](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#gslview-views).
+C++ Core Guidelines: [GSL.view: Views](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gslview-views).
-Spans and views are convenient and lightweight types that allow you to reference memory buffers. But they must be used carefully: while their interface looks similar to standard containers, their behavior is more like the behavior of pointers and references. They don't own data and must never be constructed from temporary buffers. This check focuses on cases where source data is temporary, while a span or view isn't. There's another check that handles a slightly different scenario involving span references: [C26445 NO_SPAN_REF](c26445.md). Both rules can help to avoid subtle but dangerous mistakes made when legacy code gets modernized and adopts spans or views.
+Spans and views are convenient and lightweight types that allow you to reference memory buffers. But they must be used carefully: while their interface looks similar to standard containers, their behavior is more like the behavior of pointers and references. They don't own data and must never be constructed from temporary buffers. This check focuses on cases where source data is temporary, while a span or view isn't. This rule can help to avoid subtle but dangerous mistakes made when legacy code gets modernized and adopts spans or views. There's another check that handles a slightly different scenario involving span references: [C26445 NO_SPAN_REF](c26445.md).
+
+Consider using [C26815](c26815.md) and [C26816](c26816.md). Those warnings are more general versions of this warning.
## Remarks
@@ -38,7 +40,7 @@ Subtle difference in result types:
gsl::span get_seed_sequence() noexcept;
// Returns a generated collection. Doesn't own new data.
-const std::vector get_next_sequence(gsl::span);
+std::vector get_next_sequence(gsl::span);
void run_batch()
{
@@ -50,3 +52,9 @@ void run_batch()
}
}
```
+
+To fix the issue, make sure the view is created from an object that lives at least as long as the view itself. Sometimes a solution can be achieved by copying the data, other times some APIs need to be redesigned to share a reference to an object that lives long enough instead of returning a temporary copy.
+
+## See also
+[C26815](c26815.md)\
+[C26816](c26816.md)
\ No newline at end of file
diff --git a/docs/code-quality/c26450.md b/docs/code-quality/c26450.md
index 7fc48fb269..66044efb23 100644
--- a/docs/code-quality/c26450.md
+++ b/docs/code-quality/c26450.md
@@ -1,23 +1,23 @@
---
-description: "Learn more about: Arithmetic overflow: '%operator%' operation causes overflow at compile time. Use a wider type to store the operands"
title: Warning C26450
-ms.date: 01/08/2017
+description: "Describes the causes of MSVC code analysis warning C26450 and how to fix it."
+ms.date: 05/11/2023
f1_keywords: ["C26450", "RESULT_OF_ARITHMETIC_OPERATION_PROVABLY_LOSSY"]
helpviewer_keywords: ["C26450"]
---
# Warning C26450
->Arithmetic overflow: '*operator*' operation causes overflow at compile time. Use a wider type to store the operands (io.1)
+> Arithmetic overflow: '*operator*' operation causes overflow at compile time. Use a wider type to store the operands (io.1)
## Remarks
This warning indicates that an arithmetic operation was provably lossy at compile time. It can be asserted when the operands are all compile-time constants. Currently, we check left shift, multiplication, addition, and subtraction operations for such overflows.
-Warning C4307 is a similar check in the Microsoft C++ compiler.
+Warning [C4307](../error-messages/compiler-warnings/compiler-warning-level-2-c4307.md) is a similar check in the Microsoft C++ compiler.
Code analysis name: `RESULT_OF_ARITHMETIC_OPERATION_PROVABLY_LOSSY`
-## Example 1
+## Examples
```cpp
int multiply()
@@ -36,59 +36,15 @@ long long multiply()
{
const int a = INT_MAX;
const int b = 2;
- long long c = (long long)a * b; // OK
- return c;
-}
-```
-
-## Example 2
-
-```cpp
-int add()
-{
- const int a = INT_MAX;
- const int b = 2;
- int c = a + b; // C26450 reported here
- return c;
-}
-```
-
-To correct this warning, use the following code:
-
-```cpp
-long long add()
-{
- const int a = INT_MAX;
- const int b = 2;
- long long c = (long long)a + b; // OK
- return c;
-}
-```
-
-## Example 3
-
-```cpp
-int subtract()
-{
- const int a = -INT_MAX;
- const int b = 2;
- int c = a - b; // C26450 reported here
- return c;
-}
-```
-
-To correct this warning, use the following code.
-
-```cpp
-long long subtract()
-{
- const int a = -INT_MAX;
- const int b = 2;
- long long c = (long long)a - b; // OK
+ long long c = static_cast(a) * b; // OK
return c;
}
```
## See also
-[ES.103: Don't overflow](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-overflow)
+[C26451](c26451.md)\
+[C26452](c26452.md)\
+[C26453](c26453.md)\
+[C26454](c26454.md)\
+[ES.103: Don't overflow](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es103-dont-overflow)
diff --git a/docs/code-quality/c26451.md b/docs/code-quality/c26451.md
index 2c2af3a147..0067e42718 100644
--- a/docs/code-quality/c26451.md
+++ b/docs/code-quality/c26451.md
@@ -1,7 +1,7 @@
---
title: Warning C26451
description: "Describes the causes of MSVC code analysis warning C26451, and shows how to fix it."
-ms.date: 07/15/2020
+ms.date: 05/11/2023
f1_keywords: ["C26451", "RESULT_OF_ARITHMETIC_OPERATION_CAST_TO_LARGER_SIZE"]
helpviewer_keywords: ["C26451"]
---
@@ -17,14 +17,14 @@ Code analysis detects when an integral value gets shifted left, multiplied, adde
Code analysis name: `RESULT_OF_ARITHMETIC_OPERATION_CAST_TO_LARGER_SIZE`
-## Example 1
+## Examples
The following code generates this warning:
```cpp
void leftshift(int i) noexcept
{
- unsigned __int64 x;
+ unsigned long long x;
x = i << 31; // C26451 reported here
// code
@@ -36,55 +36,17 @@ To correct this warning, use the following code:
```cpp
void leftshift(int i) noexcept
{
- unsigned __int64 x;
- x = static_cast(i) << 31; // OK
+ unsigned long long x;
+ x = static_cast(i) << 31; // OK
// code
}
```
-## Example 2
-
-```cpp
-void somefunc(__int64 /* y */) noexcept
-{}
-
-void callsomefunc(int x) noexcept
-{
- somefunc(x * 2); // C26451 reported here
-}
-```
-
-To correct this warning, use the following code:
-
-```cpp
-void callsomefunc(int x) noexcept
-{
- somefunc(static_cast<__int64>(x) * 2); // OK
-}
-```
-
-## Example 3
-
-```cpp
-__int64 add(int x) noexcept
-{
- constexpr auto value = 2;
- return x += value; // C26451 reported here
-}
-```
-
-To correct this warning, use the following code:
-
-```cpp
-__int64 add(int x) noexcept
-{
- constexpr auto value = 2;
- const __int64 y = static_cast<__int64>(x) + value; // OK
- return y;
-}
-```
-
## See also
-- [ES.103: Don't overflow](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-overflow)
+[C26450](c26450.md)\
+[C26452](c26452.md)\
+[C26453](c26453.md)\
+[C26454](c26454.md)\
+[ES.103: Don't overflow](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-overflow)
diff --git a/docs/code-quality/c26452.md b/docs/code-quality/c26452.md
index 6d54b5b539..0f529f60ce 100644
--- a/docs/code-quality/c26452.md
+++ b/docs/code-quality/c26452.md
@@ -13,14 +13,14 @@ helpviewer_keywords: ["C26452"]
This warning indicates the shift count is negative, or greater than or equal to the number of bits in the shifted operand. Either case results in undefined behavior.
-Warning C4293 is a similar check in the Microsoft C++ compiler.
+Warning [C4293](../error-messages/compiler-warnings/compiler-warning-level-1-c4293.md) is a similar check in the Microsoft C++ compiler.
Code analysis name: `SHIFT_COUNT_NEGATIVE_OR_TOO_BIG`
## Example
```cpp
-unsigned __int64 combine(unsigned lo, unsigned hi)
+unsigned long long combine(unsigned lo, unsigned hi)
{
return (hi << 32) | lo; // C26252 here
}
@@ -29,7 +29,7 @@ unsigned __int64 combine(unsigned lo, unsigned hi)
To correct this warning, use the following code:
```cpp
-unsigned __int64 combine(unsigned lo, unsigned hi)
+unsigned long long combine(unsigned lo, unsigned hi)
{
return (static_cast(hi) << 32) | lo; // OK
}
@@ -37,4 +37,9 @@ unsigned __int64 combine(unsigned lo, unsigned hi)
## See also
-[ES.102: Use signed types for arithmetic](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-unsigned)
+[C26450](c26450.md)\
+[C26451](c26451.md)\
+[C26453](c26453.md)\
+[C26454](c26454.md)\
+[ES.101: Use unsigned types for bit manipulation](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es101-use-unsigned-types-for-bit-manipulation)\
+[ES.102: Use signed types for arithmetic](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es102-use-signed-types-for-arithmetic)
diff --git a/docs/code-quality/c26453.md b/docs/code-quality/c26453.md
index 5c2a61ce75..32a7064209 100644
--- a/docs/code-quality/c26453.md
+++ b/docs/code-quality/c26453.md
@@ -1,7 +1,7 @@
---
title: Warning C26453
description: "Describes the causes of MSVC code analysis warning C26453, and shows how to fix it."
-ms.date: 07/15/2020
+ms.date: 05/11/2023
f1_keywords: ["C26453", "LEFTSHIFT_NEGATIVE_SIGNED_NUMBER"]
helpviewer_keywords: ["C26453"]
---
@@ -11,7 +11,7 @@ helpviewer_keywords: ["C26453"]
## Remarks
-This warning indicates the code left shifts a negative signed integral value, which is non-portable and triggers implementation defined behavior.
+This warning indicates the code left shifts a negative signed integral value, which is nonportable and triggers implementation defined behavior.
Code analysis name: `LEFTSHIFT_NEGATIVE_SIGNED_NUMBER`
@@ -31,7 +31,7 @@ To correct this warning, use the following code:
```cpp
void leftshift(int shiftCount)
{
- const auto result = static_cast(-1) << shiftCount; // OK
+ const auto result = ~0u << shiftCount; // OK
// code
}
@@ -39,4 +39,9 @@ void leftshift(int shiftCount)
## See also
-[ES.102: Use signed types for arithmetic](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-unsigned)
+[C26450](c26450.md)\
+[C26451](c26451.md)\
+[C26452](c26452.md)\
+[C26454](c26454.md)\
+[ES.101: Use unsigned types for bit manipulation](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es101-use-unsigned-types-for-bit-manipulation)\
+[ES.102: Use signed types for arithmetic](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es102-use-signed-types-for-arithmetic)
diff --git a/docs/code-quality/c26454.md b/docs/code-quality/c26454.md
index 4610dc5cb6..77b21092ec 100644
--- a/docs/code-quality/c26454.md
+++ b/docs/code-quality/c26454.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time"
title: Warning C26454
+description: "Learn more about: Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time"
ms.date: 01/08/2017
f1_keywords: ["C26454", "RESULT_OF_ARITHMETIC_OPERATION_NEGATIVE_UNSIGNED"]
helpviewer_keywords: ["C26454"]
@@ -37,4 +37,8 @@ unsigned int negativeunsigned()
## See also
-[ES.106: Don't try to avoid negative values by using unsigned](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-nonnegative)
+[C26450](c26450.md)\
+[C26451](c26451.md)\
+[C26452](c26452.md)\
+[C26453](c26453.md)\
+[ES.106: Don't try to avoid negative values by using `unsigned`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es106-dont-try-to-avoid-negative-values-by-using-unsigned)
diff --git a/docs/code-quality/c26455.md b/docs/code-quality/c26455.md
index 51501d72b9..617f0cedd5 100644
--- a/docs/code-quality/c26455.md
+++ b/docs/code-quality/c26455.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about the C26455 DEFAULT_CTOR_NOEXCEPT C++ Core Guidelines Checker warning. Default constructors shouldn't do anything that can throw."
title: Warning C26455
+description: "Learn more about the C26455 DEFAULT_CTOR_NOEXCEPT"
ms.date: 04/29/2022
f1_keywords: ["C26455", "DEFAULT_CTOR_NOEXCEPT"]
helpviewer_keywords: ["C26455"]
-ms.assetid: 27e86063-d969-49d8-8912-dcc2dc57249f
author: kylereedmsft
ms.author: kylereed
ms.custom: kr2b-contr-experiment
@@ -13,7 +12,7 @@ ms.custom: kr2b-contr-experiment
> Default constructor should not throw. Declare it '`noexcept`' (f.6)
-The C++ Core Guidelines suggest that default constructors shouldn't do anything that can throw. If the default constructor is allowed to throw, operations such as move and swap will also throw which is undesirable because move and swap should always succeed. Parameterized constructors may throw.
+The C++ Core Guidelines suggest that default constructors shouldn't do anything that can throw. When the default constructor can throw, all code that relies on a properly instantiated object may also throw.
## Remarks
@@ -23,4 +22,5 @@ Code analysis name: `DEFAULT_CTOR_NOEXCEPT`
## See also
-- [C++ Core Guideline F.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rf-noexcept)
+[C26439](./c26439.md)\
+[F.6: If your function must not throw, declare it `noexcept`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f6-if-your-function-must-not-throw-declare-it-noexcept)
diff --git a/docs/code-quality/c26459.md b/docs/code-quality/c26459.md
new file mode 100644
index 0000000000..0bd5855921
--- /dev/null
+++ b/docs/code-quality/c26459.md
@@ -0,0 +1,43 @@
+---
+description: "Learn more about: Warning C26459"
+title: Warning C26459
+ms.date: 4/10/2024
+f1_keywords: ["C26459", "NO_RAW_POINTER_IN_STL_RANGE_CHECKED"]
+helpviewer_keywords: ["C26459"]
+---
+# Warning C26459
+
+> You called an STL function '%function%' with a raw pointer parameter at position '%position%' that may be unsafe - this relies on the caller to check that the passed values are correct. Consider wrapping your range in a gsl::span and pass as a span iterator (stl.1)
+
+## Remarks
+
+Out of bound writes are one of the leading causes of remote code execution vulnerabilities. One remedy is to use bounds checked data structures like `gsl::span`. This warning identifies cases where Standard Template Library (STL) algorithms operate on raw pointers as output ranges. Raw pointers aren't bounds checked. To prevent vulnerabilities, use `gsl::span` instead.
+
+Code analysis name: `NO_RAW_POINTER_IN_STL_RANGE_CHECKED`
+
+## Example
+
+The following code demonstrates undefined behavior because there isn't any bounds checking and `copy_if` writes beyond the provided storage.
+
+```cpp
+void f()
+{
+ std::vector myints = { 10, 20, 30, 40, 50, 60, 70 };
+ int mydestinationArr[7] = { 10, 20, 80 };
+
+ std::copy_if(myints.begin(), myints.end(), mydestinationArr, [](int i) { return !(i<0); }); // Warning: C26459
+}
+```
+
+To fix the warning, use `gsl::span` to make sure the output range is bounds checked:
+
+```cpp
+void f()
+{
+ std::vector myints = { 10, 20, 30, 40, 50, 60, 70 };
+ int mydestinationArr[7] = { 10, 20, 80 };
+ gsl::span mySpan{mydestinationArr};
+
+ std::copy_if(myints.begin(), myints.end(), mySpan.begin(), [](int i) { return !(i<0); }); // No warning
+}
+```
\ No newline at end of file
diff --git a/docs/code-quality/c26460.md b/docs/code-quality/c26460.md
index b85910ae52..2307b0d592 100644
--- a/docs/code-quality/c26460.md
+++ b/docs/code-quality/c26460.md
@@ -24,7 +24,6 @@ struct MyStruct
void MemberFn2();
};
-
void Function1_Helper(const MyStruct&);
void Function1(MyStruct& myStruct) // C26460, see comments below.
{
diff --git a/docs/code-quality/c26478.md b/docs/code-quality/c26478.md
index 23d897a01c..ddaff2f01b 100644
--- a/docs/code-quality/c26478.md
+++ b/docs/code-quality/c26478.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26478: Don't use std::move on constant variables. (es.56)"
title: Warning C26478
-ms.date: 07/15/2019
+description: "Learn more about: Warning C26478: Don't use std::move on constant variables. (es.56)"
+ms.date: 10/12/2023
f1_keywords: ["C26478", "NO_MOVE_OP_ON_CONST"]
helpviewer_keywords: ["C26478"]
---
@@ -13,11 +13,11 @@ helpviewer_keywords: ["C26478"]
This warning is to indicate that the use of `std::move` not consistent with how `std::move` is intended to be used.
-When called on a `const` object, `std::move` returns a copy of the object, which is likely not the developer's intent.
+Because `const` objects can't be moved, calling `std::move` on them has no effect. This pattern can result in unintended copies.
Code analysis name: `NO_MOVE_OP_ON_CONST`
-## Example 1
+## Example
```cpp
struct node
@@ -33,23 +33,8 @@ void foo(const node& n)
}
```
-An assignment operator or using the passed in parameter will prevent this warning from being issued and will adequately serve the developer's use case.
-
-## Example 2
-
-```cpp
-struct s;
-
-template
-void bar(T t){};
-
-void foo()
-{
- const s s1;
- bar(std::move(s1)); // C26478 reported here
-}
-```
+To fix the issue, remove the redundant `std::move`.
## See also
-[ES.56 - Write std::move() only when you need to explicitly move an object to another scope](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es56-write-stdmove-only-when-you-need-to-explicitly-move-an-object-to-another-scope)
+[ES.56: Write `std::move()` only when you need to explicitly move an object to another scope](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es56-write-stdmove-only-when-you-need-to-explicitly-move-an-object-to-another-scope)
diff --git a/docs/code-quality/c26479.md b/docs/code-quality/c26479.md
new file mode 100644
index 0000000000..4612d6fea0
--- /dev/null
+++ b/docs/code-quality/c26479.md
@@ -0,0 +1,42 @@
+---
+title: Warning C26479
+description: "Learn more about: Warning C26479: Don't use std::move to return a local variable. (f.48)"
+ms.date: 10/12/2023
+f1_keywords: ["C26479", "NO_MOVE_RET_ON_LOCALS"]
+helpviewer_keywords: ["C26479"]
+---
+# Warning C26479
+
+> Don't use std::move to return a local variable. (f.48)
+
+## Remarks
+
+The `return` statement is the last use of a local variable, so the compiler uses move semantics to return it whenever possible.
+Adding a `std::move` is redundant in this scenario. Moreover, redundant `std::move`s can prevent copy elision.
+
+Code analysis name: `NO_MOVE_RET_ON_LOCALS`
+
+## Example 1
+
+```cpp
+S foo()
+{
+ S local1{};
+ return std::move(local1); // Warning: C26479
+}
+```
+
+To fix this issue, remove the redundant `std::move`:
+
+```cpp
+S foo()
+{
+ S local1{};
+ return local1; // No warning
+}
+```
+
+## See also
+
+[F.48: Don't `return std::move(local)`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f48-dont-return-stdmovelocal)\
+[ES.56: Write `std::move()` only when you need to explicitly move an object to another scope](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es56-write-stdmove-only-when-you-need-to-explicitly-move-an-object-to-another-scope)
diff --git a/docs/code-quality/c26483.md b/docs/code-quality/c26483.md
index ea4c10c6b9..5e031b2448 100644
--- a/docs/code-quality/c26483.md
+++ b/docs/code-quality/c26483.md
@@ -1,9 +1,9 @@
---
title: Warning C26483
+description: CppCoreCheck rule C26483 that enforces C++ Core Guidelines Bounds.2
ms.date: 03/22/2018
f1_keywords: ["C26483", "STATIC_INDEX_OUT_OF_RANGE"]
helpviewer_keywords: ["C26483"]
-description: CppCoreCheck rule C26483 that enforces C++ Core Guidelines Bounds.2
---
# Warning C26483
@@ -24,5 +24,4 @@ void function()
int arr2[] { 1, 2, 3 };
arr2[3] = 4; // C26483, 3 is outside the bounds of the array
}
-
```
diff --git a/docs/code-quality/c26488.md b/docs/code-quality/c26488.md
index b3ae0ce888..a54608facb 100644
--- a/docs/code-quality/c26488.md
+++ b/docs/code-quality/c26488.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Warning C26488 LIFETIMES_DEREF_NULL_POINTER"
title: Warning C26488
+description: "Learn more about: Warning C26488 LIFETIMES_DEREF_NULL_POINTER"
ms.date: 12/14/2018
f1_keywords: ["C26488", "LIFETIMES_DEREF_NULL_POINTER"]
helpviewer_keywords: ["C26488"]
-ms.assetid: 2ade0d31-f259-49de-8676-cce6092fabfc
author: kylereedmsft
ms.author: kylereed
---
@@ -28,9 +27,9 @@ void ex1()
The Lifetime guidelines from the C++ core guidelines outline a contract that code can follow which will enable more thorough static memory leak and dangling pointer detection. The basic ideas behind the guidelines are:
-1) Never dereference an invalid (dangling) or known-null pointer
-2) Never return (either formal return or out parameter) any pointer from a function.
-3) Never pass an invalid (dangling) pointer to any function.
+1. Never dereference an invalid (dangling) or known-null pointer.
+1. Never return (either formal return or out parameter) any pointer from a function.
+1. Never pass an invalid (dangling) pointer to any function.
## See also
diff --git a/docs/code-quality/c26489.md b/docs/code-quality/c26489.md
index 2f252dc766..85df9e569a 100644
--- a/docs/code-quality/c26489.md
+++ b/docs/code-quality/c26489.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Warning C26489 LIFETIMES_DEREF_INVALID_POINTER"
title: Warning C26489
+description: "Learn more about: Warning C26489 LIFETIMES_DEREF_INVALID_POINTER"
ms.date: 12/14/2018
f1_keywords: ["C26489", "LIFETIMES_DEREF_INVALID_POINTER"]
helpviewer_keywords: ["C26489"]
-ms.assetid: 15983d4f-f615-42e7-8521-ee094b87d066
author: kylereedmsft
ms.author: kylereed
---
@@ -30,9 +29,9 @@ int ex1()
The Lifetime guidelines from the C++ core guidelines outline a contract that code can follow which will enable more thorough static memory leak and dangling pointer detection. The basic ideas behind the guidelines are:
-1) Never dereference an invalid (dangling) or known-null pointer
-2) Never return (either formal return or out parameter) any pointer from a function.
-3) Never pass an invalid (dangling) pointer to any function.
+1. Never dereference an invalid (dangling) or known-null pointer.
+1. Never return (either formal return or out parameter) any pointer from a function.
+1. Never pass an invalid (dangling) pointer to any function.
## See also
diff --git a/docs/code-quality/c26494.md b/docs/code-quality/c26494.md
index 41cfa16b20..7ed21fb002 100644
--- a/docs/code-quality/c26494.md
+++ b/docs/code-quality/c26494.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Warning C26494 VAR_USE_BEFORE_INIT"
title: Warning C26494
+description: "Learn more about: Warning C26494 VAR_USE_BEFORE_INIT."
ms.date: 03/22/2018
f1_keywords: ["C26494", "VAR_USE_BEFORE_INIT"]
helpviewer_keywords: ["C26494"]
@@ -9,9 +9,9 @@ helpviewer_keywords: ["C26494"]
> Variable '*variable*' is uninitialized. Always initialize an object.
-## See also
+## Remarks
-[C++ Core Guidelines Type.5](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-type).
+This check requires local variables to be initialized at the declaration or in the following statement.
## Example
@@ -23,3 +23,19 @@ void function()
std::cout << myVal; // C6001
}
```
+
+To fix the issue, initialize the variable at the declaration.
+
+```cpp
+#include
+void function()
+{
+ int myVal{};
+ std::cout << myVal;
+}
+```
+
+## See also
+
+[ES.20: Always initialize an object](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es20-always-initialize-an-object)\
+[Pro.safety: Type-safety profile](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#prosafety-type-safety-profile)
diff --git a/docs/code-quality/c26495.md b/docs/code-quality/c26495.md
index f433277553..f99e5697b8 100644
--- a/docs/code-quality/c26495.md
+++ b/docs/code-quality/c26495.md
@@ -1,9 +1,9 @@
---
title: Warning C26495
-ms.date: 08/18/2022
+description: "CppCoreCheck rule that enforces C++ Core Guidelines Type.6."
+ms.date: 05/11/2023
f1_keywords: ["C26495", "MEMBER_UNINIT", "__WARNING_MEMBER_UNINIT"]
helpviewer_keywords: ["C26495"]
-description: CppCoreCheck rule that enforces C++ Core Guidelines Type.6
---
# Warning C26495
@@ -13,7 +13,9 @@ description: CppCoreCheck rule that enforces C++ Core Guidelines Type.6
A member variable isn't initialized by a constructor or by an initializer. Make sure all variables are initialized by the end of construction. For more information, see C++ Core Guidelines [Type.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-type) and [C.48](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers).
-Code analysis name: MEMBER_UNINIT
+This check is intra-procedural. Whenever there's a function call to a nonconst member function, the check assumes that this member function initializes all of the members. This heuristic can result in missed errors and is in place to avoid false positive results. Moreover, when a member is passed by nonconst reference to a function, the check assumes that the function initializes the member.
+
+Code analysis name: `MEMBER_UNINIT`
## Example
@@ -36,3 +38,7 @@ struct MyStruct
MyStruct() {} // no warning, MyStruct::value is set via default member initialization
};
```
+
+## See also
+
+[C26494](c26494.md)
\ No newline at end of file
diff --git a/docs/code-quality/c26498.md b/docs/code-quality/c26498.md
index 064ef2b92d..e495372145 100644
--- a/docs/code-quality/c26498.md
+++ b/docs/code-quality/c26498.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Warning C26498 USE_CONSTEXPR_FOR_FUNCTIONCALL"
title: Warning C26498
+description: "Learn more about: Warning C26498 USE_CONSTEXPR_FOR_FUNCTIONCALL"
ms.date: 08/18/2020
f1_keywords: ["C26498", "USE_CONSTEXPR_FOR_FUNCTIONCALL"]
helpviewer_keywords: ["C26498"]
@@ -9,15 +9,17 @@ helpviewer_keywords: ["C26498"]
> The function '*function*' is constexpr, mark variable '*variable*' constexpr if compile-time evaluation is desired (con.5)
-This rule helps to enforce Con.5 from the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con5-use-constexpr-for-values-that-can-be-computed-at-compile-time): use constexpr for values that can be computed at compile time.
+This rule helps to enforce [Con.5: Use `constexpr` for values that can be computed at compile time](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#con5-use-constexpr-for-values-that-can-be-computed-at-compile-time) in the C++ Core Guidelines.
## Remarks
The warning is triggered by assigning the result of a **`constexpr`** function to any non-**`constexpr`** variable whose value doesn't change after the initial assignment.
+Code analysis name: `USE_CONSTEXPR_FOR_FUNCTIONCALL`
+
## Example
-This sample code shows where C26498 may appear, and how to avoid it:
+This sample code shows where C26498 may appear:
```cpp
constexpr int getMyValue()
@@ -34,3 +36,28 @@ void foo()
val3 = val3 * val2;
}
```
+
+To fix the issues, mark `val1` and `val2` **`constexpr`**:
+
+```cpp
+constexpr int getMyValue()
+{
+ return 1;
+}
+
+void foo()
+{
+ constexpr int val0 = getMyValue(); // OK
+ constexpr int val1 = getMyValue(); // OK
+ constexpr int val2 = getMyValue(); // OK
+ int val3 = getMyValue(); // OK
+ val3 = val3 * val2;
+}
+```
+
+
+## See also
+
+[C26497](c26407.md)\
+[C26814](c26814.md)\
+[Con.5: Use `constexpr` for values that can be computed at compile time](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#con5-use-constexpr-for-values-that-can-be-computed-at-compile-time)
diff --git a/docs/code-quality/c26800.md b/docs/code-quality/c26800.md
index 9e0328095e..1052f0f0db 100644
--- a/docs/code-quality/c26800.md
+++ b/docs/code-quality/c26800.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Warning C26800"
title: Warning C26800
+description: "Learn more about: Warning C26800"
ms.date: 01/14/2019
f1_keywords: ["C26800", "USE_OF_A_MOVED_FROM_OBJECT"]
helpviewer_keywords: ["C26800"]
@@ -11,13 +11,42 @@ helpviewer_keywords: ["C26800"]
## Remarks
-Warning C26800 is triggered when variable is used after it has been moved from. A variable is considered moved from after it was passed to a function as rvalue reference. There are some legitimate exceptions for uses such as assignment, destruction, and some state resetting functions such as `std::vector::clear`.
+Warning C26800 is triggered when a variable is used after it has been moved from. A variable is considered moved from after it's passed to a function as rvalue reference. There are some exceptions for assignment, destruction, and some state resetting functions such as `std::vector::clear`. After using a state resetting function, we're free to use the variable. This check only reasons about the local variables.
+
+The following methods are considered state resetting methods:
+- Functions with the following case-insensitive substring in their name: `clear`, `clean`, `reset`, `free`, `destroy`, `release`, `dealloc`, `assign`
+- Overloaded assignment operators, destructor
+
+This check respects the `std::swap` operation:
+
+```cpp
+void f() {
+ Y y1, y2;
+ consume(std::move(y1));
+ std::swap(y1, y2);
+ y1.method(); // OK, valid after swap.
+ y2.method(); // warning C26800
+}
+```
+
+The check also supports the `try_emplace` operations in STL that conditionally move its argument:
+
+```cpp
+int g() {
+ std::map m;
+ Y val;
+ auto emplRes = m.try_emplace(1, std::move(val));
+ if (!emplRes.second) {
+ val.method(); // No C26800, val was not moved because the insertion did not happen.
+ }
+}
+```
Code analysis name: `USE_OF_A_MOVED_FROM_OBJECT`
## Examples
-The following code will generate C26800.
+The following code generates C26800.
```cpp
#include
@@ -37,11 +66,11 @@ void use_cref(const T&);
void test() {
X x1;
X x2 = std::move(x1);
- use_cref(x1); // @expected(26800)
+ use_cref(x1); // warning C26800
}
```
-The following code won't generate C26800.
+The following code doesn't generate C26800.
```cpp
#include
diff --git a/docs/code-quality/c26810.md b/docs/code-quality/c26810.md
index 903b6d4d0c..95c9c83644 100644
--- a/docs/code-quality/c26810.md
+++ b/docs/code-quality/c26810.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26810"
title: Warning C26810
-ms.date: 01/14/2019
+description: "Learn more about: Warning C26810."
+ms.date: 05/11/2023
f1_keywords: ["C26810", "COROUTINES_USE_AFTER_FREE_CAPTURE"]
helpviewer_keywords: ["C26810"]
---
@@ -11,13 +11,13 @@ helpviewer_keywords: ["C26810"]
## Remarks
-Warning C26810 is triggered when a memory region might be used after it went out of scope in a resumed coroutine.
+Warning C26810 is triggered when a variable might be used after its lifetime ended in a resumed coroutine.
Code analysis name: `COROUTINES_USE_AFTER_FREE_CAPTURE`
## Example
-The following code will generate C26810.
+The following code generates C26810.
```cpp
#include
@@ -66,4 +66,4 @@ Alternatively, if the coroutine is guaranteed to live shorter than the lambda ob
## See also
-- [C26811](../code-quality/c26811.md)
+[C26811](c26811.md)
diff --git a/docs/code-quality/c26811.md b/docs/code-quality/c26811.md
index 9e2d4808d3..ebdc5bcc40 100644
--- a/docs/code-quality/c26811.md
+++ b/docs/code-quality/c26811.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26811"
title: Warning C26811
-ms.date: 01/14/2019
+description: "Learn more about: Warning C26811."
+ms.date: 05/11/2023
f1_keywords: ["C26811", "COROUTINES_USE_AFTER_FREE_PARAM"]
helpviewer_keywords: ["C26811"]
---
@@ -11,13 +11,13 @@ helpviewer_keywords: ["C26811"]
## Remarks
-Warning C26811 is triggered when a memory region might be used after it went out of scope in a resumed coroutine.
+Warning C26811 is triggered when a variable might be used after its lifetime ended in a resumed coroutine.
Code analysis name: `COROUTINES_USE_AFTER_FREE_PARAM`
## Example
-The following code will generate C26811.
+The following code generates C26811.
```cpp
#include
@@ -58,4 +58,4 @@ Alternatively, when the lifetime of `a` is guaranteed to outlive the lifetime of
## See also
-- [C26810](../code-quality/c26810.md)
+[C26810](c26810.md)
diff --git a/docs/code-quality/c26813.md b/docs/code-quality/c26813.md
index 61ddbb60b7..eabce1bfec 100644
--- a/docs/code-quality/c26813.md
+++ b/docs/code-quality/c26813.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26813"
title: Warning C26813
-ms.date: 03/02/2022
+description: "Learn more about: Warning C26813"
+ms.date: 05/17/2022
f1_keywords: ["C26813", "USE_BITWISE_AND_TO_CHEK_ENUM_FLAGS", "USE_BITWISE_AND_TO_CHECK_ENUM_FLAGS"]
helpviewer_keywords: ["C26813"]
---
diff --git a/docs/code-quality/c26815.md b/docs/code-quality/c26815.md
index 3995dff0a2..5a8c319b65 100644
--- a/docs/code-quality/c26815.md
+++ b/docs/code-quality/c26815.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Warning C26815 The pointer is dangling because it points at a temporary instance that was destroyed. (ES.65)"
title: Warning C26815
+description: "Learn more about: Warning C26815."
author: Rastaban
ms.author: philc
ms.date: 01/27/2020
@@ -13,12 +13,17 @@ helpviewer_keywords: ["C26815"]
## Remarks
-There's a dangling pointer that is the result of an unnamed temporary that has been destroyed.
+The created pointer or view refers to an unnamed temporary object that is destroyed at the end of the statement. The pointer or view will dangle.
+
+This check recognizes views and owners from the C++ Standard Template Library (STL). To teach this check about user-authored types, use the `[[msvc::lifetimebound]]` annotation.
+The `[[msvc::lifetimebound]]` support is new in MSVC 17.7.
Code analysis name: `LIFETIME_LOCAL_USE_AFTER_FREE_TEMP`
## Example
+Consider the following code compiled in a C++ version before C++23:
+
```cpp
std::optional> getTempOptVec();
@@ -36,6 +41,11 @@ void views()
// Oops, the 's' suffix turns the string literal into a temporary std::string.
std::string_view value("This is a std::string"s); // warning C26815
}
+
+struct Y { int& get() [[msvc::lifetimebound]]; };
+void f() {
+ int& r = Y{}.get(); // warning C26815
+}
```
These warnings can be fixed by extending the lifetime of the temporary object.
@@ -57,8 +67,15 @@ void views()
// Fixed by changing to a constant string literal.
std::string_view value("This is a string literal");
}
+
+struct Y { int& get() [[msvc::lifetimebound]]; };
+void f() {
+ Y y{};
+ int& r = y.get();
+}
```
## See also
-[ES.65: Don't dereference an invalid pointer](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-deref)
+[C26816](c26816.md)\
+[ES.65: Don't dereference an invalid pointer](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es65-dont-dereference-an-invalid-pointer)
diff --git a/docs/code-quality/c26816.md b/docs/code-quality/c26816.md
index 9f16cf956d..f60d02ef09 100644
--- a/docs/code-quality/c26816.md
+++ b/docs/code-quality/c26816.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Warning C26816 The pointer points to memory allocated on the stack (ES.65)"
title: Warning C26816
+description: "Learn more about: Warning C26816."
author: Rastaban
ms.author: philc
ms.date: 01/27/2020
@@ -15,9 +15,12 @@ helpviewer_keywords: ["C26816"]
The pointer points to a variable that is allocated on the stack. When the variable goes out of scope it's cleaned up, which causes the pointer to be invalid.
+This check recognizes views and owners from the C++ Standard Template Library (STL). To teach this check about user-authored types, use the `[[msvc::lifetimebound]]` annotation.
+The `[[msvc::lifetimebound]]` support is new in MSVC 17.7.
+
Code analysis name: `LIFETIME_LOCAL_USE_AFTER_FREE_STACK`
-## Example
+## Examples
```cpp
// In this example, std::string is being used internally because the implementer felt it was easier to
@@ -27,7 +30,13 @@ const char *danglingRawPtrFromLocal() {
// interesting string initialization here
- return s.c_str(); // Oops, The pointer points to memory allocated on the stack
+ return s.c_str(); // Oops, The pointer points to memory that will be cleaned up upon return. Warning C26816.
+}
+
+struct Y { int& get() [[msvc::lifetimebound]]; };
+int& f() {
+ Y y;
+ return y.get(); // Warning C26826
}
```
@@ -42,8 +51,15 @@ std::string danglingRawPtrFromLocal() {
return s;
}
+
+struct Y { int& get() [[msvc::lifetimebound]]; };
+int f() {
+ Y y;
+ return y.get();
+}
```
## See also
-[ES.65: Don't dereference an invalid pointer](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-deref)
+[C26815](c26815.md)\
+[ES.65: Don't dereference an invalid pointer](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es65-dont-dereference-an-invalid-pointer)
diff --git a/docs/code-quality/c26817.md b/docs/code-quality/c26817.md
index 2c61af2727..3e66b660cf 100644
--- a/docs/code-quality/c26817.md
+++ b/docs/code-quality/c26817.md
@@ -1,7 +1,7 @@
---
title: Warning C26817
description: "Reference for Microsoft C++ Code Analysis warning C26817 in Visual Studio."
-ms.date: 02/24/2020
+ms.date: 10/12/2023
f1_keywords: ["C26817"]
helpviewer_keywords: ["C26817"]
---
@@ -9,7 +9,7 @@ helpviewer_keywords: ["C26817"]
> Potentially expensive copy of variable *name* in range-for loop. Consider making it a const reference (es.71).
-For more information, see [ES.71 notes](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#note-214) in the C++ Core Guidelines.
+For more information, see [ES.71: Prefer a range-`for`-statement to a `for`-statement when there is a choice](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es71-prefer-a-range-for-statement-to-a-for-statement-when-there-is-a-choice) in the C++ Core Guidelines.
## Example
@@ -25,7 +25,7 @@ class MyComplexType {
void expensive_function(std::vector& complex_vector_ref)
{
- for (auto item: complex_vector_ref)
+ for (auto item: complex_vector_ref) // Warning: C26817
{
// At each iteration, item gets a copy of the next element
// ...
@@ -38,9 +38,7 @@ void expensive_function(std::vector& complex_vector_ref)
}
```
-This behavior is fine for scalars (pointers, arithmetic types, and so on), but for larger types, the copying may become expensive.
-
-## Solution
+The warning is ignoring some types that are cheap to copy like for scalars (pointers, arithmetic types, and so on).
To fix this issue, if the loop variable isn't mutated anywhere in the loop, make it a const reference:
@@ -67,4 +65,4 @@ void less_expensive_function(std::vector& complex_vector_ref)
}
```
-The **`const`** keyword makes the loop variable immutable. Use of a non-const reference may cause potentially unwanted side effects in the original container elements. If you need to modify only the local loop variable, the potentially expensive copying is unavoidable.
+The **`const`** keyword makes the loop variable immutable. Use of a non-const reference makes it possible to inadvertently use the reference to modify the container's elements. If you need to modify only the local loop variable, the potentially expensive copying is unavoidable.
diff --git a/docs/code-quality/c26819.md b/docs/code-quality/c26819.md
index dc8713deb5..fea652f765 100644
--- a/docs/code-quality/c26819.md
+++ b/docs/code-quality/c26819.md
@@ -13,11 +13,11 @@ helpviewer_keywords: ["C26819"]
This check covers implicit fallthrough in switch statements. Implicit fallthrough is when control flow transfers from one switch case directly into a following switch case without the use of the `[[fallthrough]];` statement. This warning is raised when an implicit fallthrough is detected in a switch case containing at least one statement.
-For more information, see [ES.78: Don't rely on implicit fallthrough in `switch` statements](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-break) in the C++ Core Guidelines.
+For more information, see [ES.78: Don't rely on implicit fallthrough in `switch` statements](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es78-dont-rely-on-implicit-fallthrough-in-switch-statements) in the C++ Core Guidelines.
## Example
-In this sample, implicit fallthrough occurs from a non-empty switch case into a following case.
+In this sample, implicit fallthrough occurs from a nonempty `switch` `case` into a following `case`.
```cpp
void fn1();
@@ -27,10 +27,10 @@ void foo(int a)
{
switch (a)
{
- case 0: // implicit fallthrough from case 0 to case 1 is OK because case 0 is empty
+ case 0: // implicit fallthrough from case 0 to case 1 is OK because case 0 is empty
case 1:
fn1(); // implicit fallthrough from case 1 into case 2
- case 2:
+ case 2: // Warning C26819.
fn2();
break;
default:
@@ -39,8 +39,6 @@ void foo(int a)
}
```
-## Solution
-
To fix this issue, insert a `[[fallthrough]];` statement where the fallthrough occurs.
```cpp
@@ -86,3 +84,7 @@ void foo(int a)
}
}
```
+
+## See also
+
+[ES.78: Don't rely on implicit fallthrough in `switch` statements](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es78-dont-rely-on-implicit-fallthrough-in-switch-statements)
diff --git a/docs/code-quality/c26820.md b/docs/code-quality/c26820.md
index 926ec23bf1..133edaf130 100644
--- a/docs/code-quality/c26820.md
+++ b/docs/code-quality/c26820.md
@@ -1,17 +1,17 @@
---
title: Warning C26820
description: "Reference for Microsoft C++ Code Analysis warning C26820 in Visual Studio."
-ms.date: 04/07/2020
+ms.date: 10/12/2023
f1_keywords: ["C26820"]
helpviewer_keywords: ["C26820"]
---
# Warning C26820
-> Assigning by value when a const-reference would suffice, use const auto& instead (p.9).
+> This is a potentially expensive copy operation. Consider using a reference unless a copy is required (p.9)
-For more information, see [P.9: Don't waste time or space](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#p9-dont-waste-time-or-space) in the C++ Core Guidelines.
+For more information, see [P.9: Don't waste time or space](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#p9-dont-waste-time-or-space) in the C++ Core Guidelines.
-This check covers non-obvious and easy-to-miss behavior when assigning a reference to a variable marked **`auto`**. The type of the **`auto`** variable is resolved to a value rather than a reference, and an implicit copy is made.
+This check covers nonobvious and easy-to-miss behavior when assigning a reference to a variable marked **`auto`**. The type of the **`auto`** variable is resolved to a value rather than a reference, and an implicit copy is made.
## Remarks
diff --git a/docs/code-quality/c26826.md b/docs/code-quality/c26826.md
index 8c0f827e9d..47fd2d9e8d 100644
--- a/docs/code-quality/c26826.md
+++ b/docs/code-quality/c26826.md
@@ -9,7 +9,7 @@ helpviewer_keywords: ["C26826"]
> Don't use C-style variable arguments (f.55).
-For more information, see [F.55: Don't use `va_arg` arguments](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#F-varargs) in the C++ Core Guidelines.
+For more information, see [F.55: Don't use `va_arg` arguments](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f55-dont-use-va_arg-arguments) in the C++ Core Guidelines.
## Remarks
diff --git a/docs/code-quality/c26827.md b/docs/code-quality/c26827.md
index 4fa10fc07f..7f80abb532 100644
--- a/docs/code-quality/c26827.md
+++ b/docs/code-quality/c26827.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26827"
title: Warning C26827
-ms.date: 03/02/2022
+description: "Learn more about: Warning C26827"
+ms.date: 05/17/2023
f1_keywords: ["C26827", "ALMOST_BITWISE_ENUM"]
helpviewer_keywords: ["C26827"]
---
diff --git a/docs/code-quality/c26828.md b/docs/code-quality/c26828.md
index ee3f102c2c..5c0a9d474d 100644
--- a/docs/code-quality/c26828.md
+++ b/docs/code-quality/c26828.md
@@ -1,7 +1,7 @@
---
-description: "Learn more about: Warning C26828"
title: Warning C26828
-ms.date: 03/02/2022
+description: "Learn more about: Warning C26828"
+ms.date: 05/17/2023
f1_keywords: ["C26828", "MIXING_OVERLAPPING_ENUMS"]
helpviewer_keywords: ["C26828"]
---
diff --git a/docs/code-quality/c26831.md b/docs/code-quality/c26831.md
new file mode 100644
index 0000000000..fba6057d2f
--- /dev/null
+++ b/docs/code-quality/c26831.md
@@ -0,0 +1,63 @@
+---
+title: Warning C26831
+description: "Describes the Microsoft C/C++ code analysis warning C26831, its causes, and how to address it."
+ms.date: 03/20/2023
+f1_keywords: ["C26831", "ALLOCATION_POTENTIAL_OVERFLOW"]
+helpviewer_keywords: ["C26831"]
+---
+# Warning `C26831`
+
+> Allocation size might be the result of a numerical overflow
+
+## Remarks
+
+This warning reports that the size specified for an allocation may be the result of a numerical overflow. For example:
+
+```cpp
+void *SmallAlloc(int);
+
+void foo(int i, int j)
+{
+ int* p = (int*)SmallAlloc(i + j); // Warning: C26831
+ p[i] = 5;
+}
+```
+
+If `i+j` overflows, `SmallAlloc` returns a buffer that is smaller than expected. That will likely lead to out of bounds attempts to access the buffer later on. This code pattern can result in remote code execution vulnerabilities.
+
+The check applies to common allocation functions like `new`, `malloc`, and `VirtualAlloc`. The check also applies to custom allocator functions that have `alloc` (case insensitive) in the function name.
+
+This check sometimes fails to recognize that certain checks can prevent overflows because the check is conservative.
+
+This warning is available in Visual Studio 2022 version 17.7 and later versions.
+
+## Example
+
+To fix the previous code example in which `i+j` might overflow, introduce a check to make sure it won't. For example:
+
+```cpp
+void *SmallAlloc(int);
+
+void foo(int i, int j)
+{
+ if (i < 0 || j < 0 )
+ {
+ return;
+ }
+
+ if (i > 100 || j > 100)
+ {
+ return;
+ }
+
+ int* p = (int*)SmallAlloc(i + j);
+ p[i] = 5;
+}
+```
+
+## See also
+
+[`C26832`](c26832.md)\
+[`C26833`](c26833.md)\
+[`C26838`](c26838.md)\
+[`C26839`](c26839.md)
\ No newline at end of file
diff --git a/docs/code-quality/c26832.md b/docs/code-quality/c26832.md
new file mode 100644
index 0000000000..adf379b5ca
--- /dev/null
+++ b/docs/code-quality/c26832.md
@@ -0,0 +1,58 @@
+---
+title: Warning C26832
+description: "Describes the Microsoft C/C++ code analysis warning C26832, its causes, and how to address it."
+ms.date: 03/20/2023
+f1_keywords: ["C26832", "ALLOCATION_POTENTIAL_OVERFLOW_AFTER_CAST"]
+helpviewer_keywords: ["C26832"]
+---
+# Warning `C26832`
+
+> Allocation size is the result of a narrowing conversion that could result in overflow
+
+## Remarks
+
+This warning reports that the size specified for an allocation may be the result of a narrowing conversion that results in a numerical overflow. For example:
+
+```cpp
+void* SmallAlloc(int);
+
+void foo(unsigned short i, unsigned short j)
+{
+ unsigned short size = i + j;
+
+ int* p = (int*)SmallAlloc(size); // Warning: C26832
+ p[i] = 5;
+}
+```
+
+In the expression `i + j`, both `i` and `j` are promoted to integers, and the result of the addition is stored in a temporary integer. Then, the temporary integer is implicitly cast to an `unsigned short` before the value is stored in `size`. The cast to `unsigned short` might overflow, in which case `SmallAlloc` may return a smaller buffer than expected. That will likely lead to out of bounds attempts to access the buffer later on. This code pattern can result in remote code execution vulnerabilities
+
+This check applies to common allocation functions like `new`, `malloc`, and `VirtualAlloc`. The check also applies to custom allocator functions that have `alloc` (case insensitive) in the function name.
+
+This check sometimes fails to recognize that certain checks can prevent overflows because the check is conservative.
+
+This warning is available in Visual Studio 2022 version 17.7 and later versions.
+
+## Example
+
+To fix the previous code example in which `i+j` might overflow, introduce a check to make sure it won't. For example:
+
+```cpp
+void *SmallAlloc(int);
+
+void foo(unsigned short i, unsigned short j)
+{
+ if (i > 100 || j > 100)
+ return;
+
+ unsigned short size = i + j;
+
+ int* p = (int*)SmallAlloc(size);
+ p[i] = 5;
+}
+```
+
+## See also
+
+[`C26831`](c26831.md)\
+[`C26833`](c26833.md)
\ No newline at end of file
diff --git a/docs/code-quality/c26833.md b/docs/code-quality/c26833.md
new file mode 100644
index 0000000000..f751948098
--- /dev/null
+++ b/docs/code-quality/c26833.md
@@ -0,0 +1,70 @@
+---
+title: Warning C26833
+description: "Describes the Microsoft C/C++ code analysis warning C26833, its causes, and how to address it."
+ms.date: 03/20/2023
+f1_keywords: ["C26833", "ALLOCATION_POTENTIAL_OVERFLOW_BEFORE_CHECK"]
+helpviewer_keywords: ["C26833"]
+---
+# Warning `C26833`
+
+> Allocation size might be the result of a numerical overflow before the bound check
+
+## Remarks
+
+This warning reports that the size specified for an allocation may be the result of a numerical overflow. For example:
+
+```cpp
+void* SmallAlloc(int);
+
+void foo(unsigned i, unsigned j)
+{
+ unsigned size = i + j;
+
+ if (size > 50)
+ {
+ return;
+ }
+
+ int* p = (int*)SmallAlloc(size + 5); // Warning: C26833
+ p[j] = 5;
+}
+```
+
+The check for `size > 50` is too late. If `i + j` overflows, it produces a small value that passes the check. Then, `SmallAlloc` allocates a buffer smaller than expected. That will likely lead to out of bounds attempts to access the buffer later on. This code pattern can result in remote code execution vulnerabilities.
+
+This check applies to common allocation functions like `new`, `malloc`, and `VirtualAlloc`. The check also applies to custom allocator functions that have `alloc` (case insensitive) in the function name.
+
+This check sometimes fails to recognize that certain checks can prevent overflows because the check is conservative.
+
+This warning is available in Visual Studio 2022 version 17.7 and later versions.
+
+## Example
+
+To fix the previous code example, make sure `i+j` can't overflow. For example:
+
+```cpp
+void* SmallAlloc(int);
+
+void foo(unsigned i, unsigned j)
+{
+ if (i > 100 || j > 100)
+ {
+ return;
+ }
+
+ unsigned size = i + j;
+
+ if (size > 50)
+ {
+ return;
+ }
+
+ int* p = (int*)SmallAlloc(size + 5);
+ p[j] = 5;
+}
+```
+
+## See also
+
+[`C26831`](c26831.md)\
+[`C26832`](c26832.md)
\ No newline at end of file
diff --git a/docs/code-quality/c26835.md b/docs/code-quality/c26835.md
new file mode 100644
index 0000000000..1070ca73fd
--- /dev/null
+++ b/docs/code-quality/c26835.md
@@ -0,0 +1,45 @@
+---
+title: Warning C26835
+description: "Describes the Microsoft C/C++ code analysis warning C26835, its causes, and how to address it."
+ms.date: 03/20/2023
+f1_keywords: ["C26835", "RTL_COMPARE_MEMORY_MISUSE"]
+helpviewer_keywords: ["C26835"]
+---
+# Warning `C26835`
+
+> `RtlCompareMemory` returns the number of matching bytes. Consider replacing this call with `RtlEqualMemory`
+
+## Remarks
+
+When `RtlCompareMemory`'s return value is treated as a boolean, it evaluates to true when there is at least 1 equal byte before finding a difference. Moreover, comparing the result of `RtlCompareMemory` to 0 evaluates to false if there is at least 1 matching byte. This behavior may be unexpected because it's different from other comparison functions such as `strcmp`, making the code harder to understand. To check for equality, consider using `RtlEqualMemory` instead.
+
+This warning is available in Visual Studio 2022 version 17.7 and later versions.
+
+## Example
+
+```cpp
+int foo(const void* ptr)
+{
+ if (RtlCompareMemory("test", ptr, 5) == 0) // C26835
+ {
+ // ...
+ }
+}
+```
+
+To fix the issue, verify if the original intention was to check for equality and replace the function call with `RtlEqualMemory`:
+
+```cpp
+int foo(const void* ptr)
+{
+ if (RtlEqualMemory("test", ptr, 5)) // C26835
+ {
+ // ...
+ }
+}
+```
+
+## See also
+
+[`RtlEqualMemory` macro (`wdm.h`)](/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlequalmemory)\
+[`RtlCompareMemory` function (`wdm.h`)](/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlcomparememory)
\ No newline at end of file
diff --git a/docs/code-quality/c26837.md b/docs/code-quality/c26837.md
new file mode 100644
index 0000000000..2be95d94db
--- /dev/null
+++ b/docs/code-quality/c26837.md
@@ -0,0 +1,143 @@
+---
+title: Warning C26837
+description: "Learn more about: Warning C26837"
+ms.date: 11/29/2023
+f1_keywords: ["C26837", "INTERLOCKED_COMPARE_EXCHANGE_MISUSE", "__WARNING_INTERLOCKED_COMPARE_EXCHANGE_MISUSE"]
+helpviewer_keywords: ["C26837"]
+---
+# Warning C26837
+
+> Value for the comparand `comp` for function `func` has been loaded from the destination location `dest` through non-volatile read.
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+The [`InterlockedCompareExchange`](/windows/win32/api/winnt/nf-winnt-interlockedcompareexchange) function, and its derivatives such as [`InterlockedCompareExchangePointer`](/windows/win32/api/winnt/nf-winnt-interlockedcompareexchangepointer), perform an atomic compare-and-exchange operation on the specified values. If the `Destination` value is equal to the `Comparand` value, the *exchange* value is stored in the address specified by `Destination`. Otherwise, no operation is performed. The `interlocked` functions provide a simple mechanism for synchronizing access to a variable that is shared by multiple threads. This function is atomic with respect to calls to other `interlocked` functions. Misuse of these functions can generate object code that behaves differently than you expect because optimization can change the behavior of the code in unexpected ways.
+
+Consider the following code:
+
+```cpp
+#include
+
+bool TryLock(__int64* plock)
+{
+ __int64 lock = *plock;
+ return (lock & 1) &&
+ _InterlockedCompareExchange64(plock, lock & ~1, lock) == lock;
+}
+```
+
+The intent of this code is:
+
+1. Read the current value from the `plock` pointer.
+1. Check if this current value has the least significant bit set.
+1. If it does have least significant bit set, clear the bit while preserving the other bits of the current value.
+
+To accomplish this, a copy of the current value is read from the `plock` pointer and saved to a stack variable `lock`. `lock` is used three times:
+
+1. First, to check if the least-significant bit is set.
+1. Second, as the `Comparand` value to `InterlockedCompareExchange64`.
+1. Finally, in the comparison of the return value from `InterlockedCompareExchange64`
+
+This assumes that the current value saved to the stack variable is read once at the start of the function and doesn't change. This is necessary because the current value is first checked before attempting the operation, then explicitly used as the `Comparand` in `InterlockedCompareExchange64`, and finally used to compare the return value from `InterlockedCompareExchange64`.
+
+Unfortunately, the previous code can be compiled into assembly that behaves differently than from what you expect from the source code. Compile the previous code with the Microsoft Visual C++ (MSVC) compiler and the [`/O1`](../build/reference/o1-o2-minimize-size-maximize-speed.md) option and inspect the resultant assembly code to see how the value of the lock for each of the references to `lock` is obtained. The MSVC compiler version v19.37 produces assembly code that looks like:
+
+```x86asm
+plock$ = 8
+bool TryLock(__int64 *) PROC ; TryLock, COMDAT
+ mov r8b, 1
+ test BYTE PTR [rcx], r8b
+ je SHORT $LN3@TryLock
+ mov rdx, QWORD PTR [rcx]
+ mov rax, QWORD PTR [rcx]
+ and rdx, -2
+ lock cmpxchg QWORD PTR [rcx], rdx
+ je SHORT $LN4@TryLock
+$LN3@TryLock:
+ xor r8b, r8b
+$LN4@TryLock:
+ mov al, r8b
+ ret 0
+bool TryLock(__int64 *) ENDP ; TryLock
+```
+
+`rcx` holds the value of the parameter `plock`. Rather than make a copy of the current value on the stack, the assembly code is re-reading the value from `plock` every time. This means the value could be different each time it's read. This invalidates the sanitization that the developer is performing. The value is re-read from `plock` after it's verified that it has its least-significant bit set. Because it's re-read after this validation is performed, the new value might no longer have the least-significant bit set. Under a race condition, this code might behave as if it successfully obtained the specified lock when it was already locked by another thread.
+
+The compiler is allowed to remove or add memory reads or writes as long as the behavior of the code isn't altered. To prevent the compiler from making such changes, force reads to be `volatile` when you read the value from memory and cache it in a variable. Objects that are declared as `volatile` aren't used in certain optimizations because their values can change at any time. The generated code always reads the current value of a `volatile` object when it's requested, even if a previous instruction asked for a value from the same object. The reverse also applies for the same reason. The value of the `volatile` object isn't read again unless requested. For more information about `volatile`, see [`volatile`](..\cpp\volatile-cpp.md). For example:
+
+```cpp
+#include
+
+bool TryLock(__int64* plock)
+{
+ __int64 lock = *static_cast(plock);
+ return (lock & 1) &&
+ _InterlockedCompareExchange64(plock, lock & ~1, lock) == lock;
+}
+```
+
+Compile this code with same [`/O1`](../build/reference/o1-o2-minimize-size-maximize-speed.md) option as before. The generated assembly no longer reads `plock` for use of the cached value in `lock`.
+
+For more examples of how the code can be fixed, see [Example](#example).
+
+Code analysis name: `INTERLOCKED_COMPARE_EXCHANGE_MISUSE`
+
+## Example
+
+The compiler might optimize the following code to read `plock` multiple times instead of using the cached value in `lock`:
+
+```cpp
+#include
+
+bool TryLock(__int64* plock)
+{
+ __int64 lock = *plock;
+ return (lock & 1) &&
+ _InterlockedCompareExchange64(plock, lock & ~1, lock) == lock;
+}
+```
+
+To fix the problem, force reads to be `volatile` so that the compiler doesn't optimize code to read successively from the same memory unless explicitly instructed. This prevents the optimizer from introducing unexpected behavior.
+
+The first method to treat memory as `volatile` is to take the destination address as `volatile` pointer:
+
+```cpp
+#include
+
+bool TryLock(volatile __int64* plock)
+{
+ __int64 lock = *plock;
+ return (lock & 1) &&
+ _InterlockedCompareExchange64(plock, lock & ~1, lock) == lock;
+}
+```
+
+The second method is using `volatile` read from the destination address. There are a few different ways to do this:
+
+- Casting the pointer to `volatile` pointer before dereferencing the pointer
+- Creating a `volatile` pointer from the provided pointer
+- Using `volatile` read helper functions.
+
+For example:
+
+```cpp
+#include
+
+bool TryLock(__int64* plock)
+{
+ __int64 lock = ReadNoFence64(plock);
+ return (lock & 1) &&
+ _InterlockedCompareExchange64(plock, lock & ~1, lock) == lock;
+}
+```
+
+## Heuristics
+
+This rule is enforced by detecting if the value in the `Destination` of the `InterlockedCompareExchange` function, or any of its derivatives, is loaded through a non-`volatile` read, and then used as the `Comparand` value. However, it doesn't explicitly check if the loaded value is used to determine the *exchange* value. It assumes the *exchange* value is related to the `Comparand` value.
+
+## See also
+
+[`InterlockedCompareExchange` function (winnt.h)](/windows/win32/api/winnt/nf-winnt-interlockedcompareexchange)\
+[`_InterlockedCompareExchange` intrinsic functions](../intrinsics/interlockedcompareexchange-intrinsic-functions.md)
diff --git a/docs/code-quality/c26838.md b/docs/code-quality/c26838.md
new file mode 100644
index 0000000000..652ec704cd
--- /dev/null
+++ b/docs/code-quality/c26838.md
@@ -0,0 +1,62 @@
+---
+title: Warning C26838
+description: Learn about Microsoft C++ code analysis warning C26838.
+author: Rastaban
+ms.author: philc
+ms.topic: reference
+ms.date: 1/10/2025
+---
+# Warning C26838
+
+> Allocation size is the result of a signed to unsigned narrowing conversion that could result in overflow if the signed value is negative.
+
+This warning was added in Visual Studio 2022 version 17.13.
+
+## Remarks
+
+Reports that the size specified for an allocation may be the result of the conversion of a possibly negative signed value to an unsigned value. For example:
+
+```cpp
+void* CustomAlloc(size_t);
+
+int* CreateIntArray(int numberOfElements)
+{
+ int* p = (int*)CustomAlloc(numberOfElements * sizeof(int)); // Warning: C26838
+
+ return p;
+}
+```
+
+The expression `numberOfElements * sizeof(int)`, `numberOfElements` is signed and `sizeof(int)` is unsigned. On 64-bit machines, `numberOfElements` is promoted to an unsigned value when multiplied
+by `sizeof(int)`. When `numberOfElements` is negative, the resulting value may overflow or have unexpected results when passed to `CustomAlloc`.
+
+This check applies to common allocation functions like `new`, `malloc`, and `VirtualAlloc`. The check also applies to custom allocator functions that have `alloc` (case insensitive) in the function name.
+
+This check sometimes fails to recognize that certain checks can prevent overflows because the check is conservative.
+
+## Example
+
+To fix the previous code example in which `numberOfElements * sizeof(int)` might overflow due to a negative signed value, introduce a check to ensure it won't. For example:
+
+```cpp
+void* CustomAlloc(size_t);
+
+int* CreateIntArray(int numberOfElements)
+{
+ if (numberOfElements < 0)
+ return nullptr;
+
+ int* p = (int*)CustomAlloc(numberOfElements * sizeof(int));
+ // ...
+ return p;
+}
+```
+
+In the previous example, checking for a negative value addresses the `C26832` warning. Depending on the size of the types involved, this check may result in a different warning such as [`C26831`](c26831.md). For example, on a 32-bit system, both `int` and `size_t` are 32 bits, so the result of the multiplication can still overflow without negative values.
+
+## See also
+
+[`C26831`](c26831.md)\
+[`C26832`](c26832.md)\
+[`C26833`](c26833.md)\
+[`C26833`](c26839.md)
\ No newline at end of file
diff --git a/docs/code-quality/c26839.md b/docs/code-quality/c26839.md
new file mode 100644
index 0000000000..96d47c6df2
--- /dev/null
+++ b/docs/code-quality/c26839.md
@@ -0,0 +1,53 @@
+---
+title: Warning C26839
+description: Learn about Microsoft C++ code analysis warning C26839.
+author: Rastaban
+ms.author: philc
+ms.topic: reference
+ms.date: 1/10/2025
+---
+# Warning C26839
+
+> Array new allocation size is the result of a signed to unsigned narrowing conversion that could result in overflow if the signed value is negative.
+
+This warning was added in Visual Studio 2022 version 17.13.
+
+## Remarks
+
+Reports that the size specified for an array `new` allocation may be the result of the conversion of a possibly negative signed value to an unsigned value. For example:
+
+```cpp
+int* CreateIntArray(int size)
+{
+ int* intArray = new int[size];
+ return intArray;
+}
+```
+
+The expression `new int[size]`, `size` is signed. The compiler converts the signed value to an unsigned value to calculate how many bytes to be allocated for the array. When `size` is negative, the result of that calculation may overflow or have unexpected results when passed to `new`.
+
+This check is the same as [`C26838`](c26838.md), but applies only to `new T[]`.
+
+This check sometimes fails to recognize that certain checks can prevent overflows because the check is conservative.
+
+## Example
+
+To fix the previous code example in which the size calculation might overflow due to a negative signed value, introduce a check to ensure it won't. For example:
+
+```cpp
+int* CreateIntArray(int size)
+{
+ if (size < 0)
+ return nullptr;
+
+ int* intArray = new int[size];
+ return intArray;
+}
+```
+
+## See also
+
+[`C26831`](c26831.md)\
+[`C26832`](c26832.md)\
+[`C26838`](c26833.md)\
+[`C26838`](c26838.md)
\ No newline at end of file
diff --git a/docs/code-quality/c26861.md b/docs/code-quality/c26861.md
new file mode 100644
index 0000000000..2346fa7afd
--- /dev/null
+++ b/docs/code-quality/c26861.md
@@ -0,0 +1,69 @@
+---
+description: "Learn more about: Warning C26861"
+title: Warning C26861
+ms.date: 11/29/2023
+f1_keywords: ["C26861", "DATETIME_MANIPULATION_WITHOUT_LEAPYEAR_CHECK", "__WARNING_DATETIME_MANIPULATION_WITHOUT_LEAPYEAR_CHECK"]
+helpviewer_keywords: ["C26861"]
+---
+# Warning C26861
+
+> Field of a date-time object `var` has been modified without proper leap year checking: `expr`
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+In the Gregorian calendar, every year exactly divisible by four is a leap year--except for years that are exactly divisible by 100. The centurial years are also leap years if they're exactly divisible by 400.
+
+A leap year bug occurs when software doesn't account for this leap year logic, or uses flawed logic. The can affect reliability, availability, or even the security of the affected system.
+
+It isn't safe to add or subtract some number to or from the year, month, or day field of a date-time object without taking leap years into account. This calculation is commonly performed to determine the expiration date for a certificate, for example. On many dates, a naive calculation may produce the desired result. However, when the result is February 29 (a leap day) and the year isn't a leap year, the result is invalid.
+
+For example, adding a year to 2020-01-31 produces 2021-01-31. But adding a year to 2020-02-29 produces 2021-02-29, which isn't a valid date because 2021 isn't a leap year.
+
+Be cautious when manipulating variables that represent date values. Handle leap years and leap days properly, or use an API or library that handles date arithmetic safely.
+
+Code analysis name: `DATETIME_MANIPULATION_WITHOUT_LEAPYEAR_CHECK`
+
+## Example
+
+The following code advances the system time by a year by incrementing the year field of the date-time object representing the system time. However, it can produce an invalid date-time object if the date was February 29 before the modification, because the next year isn't a leap year:
+
+```cpp
+SYSTEMTIME st;
+GetSystemTime(&st);
+st.wYear++; // warning C26861
+```
+
+To avoid creating an invalid date-time object due to a leap year, check if the resulting date is still valid and make the necessary adjustments to make it valid, as in this example:
+
+```cpp
+SYSTEMTIME st;
+GetSystemTime(&st);
+st.wYear++;
+if (st.wMonth == 2 && st.wDay == 29)
+{
+ // move back a day when landing on Feb 29 in a non-leap year
+ bool isLeapYear = st.wYear % 4 == 0 && (st.wYear % 100 != 0 || st.wYear % 400 == 0);
+ if (!isLeapYear)
+ {
+ st.wDay = 28;
+ }
+}
+```
+
+## Heuristics
+
+Currently, this rule only recognizes the Windows `SYSTEMTIME` struct and C `tm` struct.
+
+This rule employs a simplified heuristic to find potentially risky changes and reports warnings unless there's appropriate leap year or leap day checking. It doesn't try to verify if the leap year or leap day checking is performed correctly for the modified date-time object.
+
+This rule is an opt-in rule, which means that code analysis should use a ruleset file, and the rule should be explicitly included in the ruleset file, and enabled for it to be applied. For more information on creating a custom ruleset for code analysis, see: [Use Rule Sets to Specify the `C++` Rules to Run](using-rule-sets-to-specify-the-cpp-rules-to-run.md).
+
+## See also
+
+[C6393](c6393.md)\
+[C6394](c6394.md)\
+[C26862](c26862.md)\
+[C26863](c26863.md)\
+[C26864](c26864.md)
diff --git a/docs/code-quality/c26862.md b/docs/code-quality/c26862.md
new file mode 100644
index 0000000000..f56e78753c
--- /dev/null
+++ b/docs/code-quality/c26862.md
@@ -0,0 +1,64 @@
+---
+description: "Learn more about: Warning C26862"
+title: Warning C26862
+ms.date: 11/29/2023
+f1_keywords: ["C26862", "INCOMPLETE_DATETIME_CONVERSION", "__WARNING_INCOMPLETE_DATETIME_CONVERSION"]
+helpviewer_keywords: ["C26862"]
+---
+# Warning C26862
+
+> A date-time object `var` has been created from a different type of date-time object but conversion was incomplete: `expr`
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+Proper enforcement of leap year and leap day handling rules require tracking the proper conversion between date-time objects of different types such as the Windows `SYSTEMTIME` struct and the C `tm` struct. Different date-time types may have different bases for the year, month, and day fields. For example, `SYSTEMTIME` has a 0-based year, but 1-based month and day fields. On the other hand, `tm` has a 1900-based year, a 0-based month, and a 1-based day fields. To convert an object of one of these types to an object of another type, the year, month, and day fields must be adjusted appropriately.
+
+Code analysis name: `INCOMPLETE_DATETIME_CONVERSION`
+
+## Example
+
+The following code tries to convert an instance of `tm` into an instance of `SYSTEMTIME`. It makes the necessary adjustment to the year field, but doesn't properly adjust the month field:
+
+```cpp
+#include
+#include
+
+void ConvertTmToSystemTime1b(const tm& tm)
+{
+ SYSTEMTIME st;
+ st.wYear = tm.tm_year + 1900;
+ st.wMonth = tm.tm_mon; // C26862, Adjustment is missing
+ st.wDay = tm.tm_mday;
+}
+```
+
+To fix this problem, adjust the month and year fields:
+
+```cpp
+#include
+#include
+
+void ConvertTmToSystemTime(const tm& tm)
+{
+ SYSTEMTIME st;
+ st.wYear = tm.tm_year + 1900;
+ st.wMonth = tm.tm_mon + 1;
+ st.wDay = tm.tm_mday;
+}
+```
+
+## Heuristics
+
+This rule only recognizes the Windows `SYSTEMTIME` struct and the C `tm` struct.
+
+This rule is an opt-in rule, meaning that code analysis should use a ruleset file, and the rule should be explicitly included in the ruleset file, and enabled for it to be applied. For more information on creating a custom ruleset for code analysis, see [Use Rule Sets to Specify the `C++` Rules to Run](using-rule-sets-to-specify-the-cpp-rules-to-run.md).
+
+## See also
+
+[C6393](c6393.md)\
+[C6394](c6394.md)\
+[C26861](c26861.md)\
+[C26863](c26863.md)\
+[C26864](c26864.md)
diff --git a/docs/code-quality/c26863.md b/docs/code-quality/c26863.md
new file mode 100644
index 0000000000..169368c8df
--- /dev/null
+++ b/docs/code-quality/c26863.md
@@ -0,0 +1,83 @@
+---
+description: "Learn more about: Warning C26863"
+title: Warning C26863
+ms.date: 11/29/2023
+f1_keywords: ["C26863", "DATETIME_MANIPULATION_FUNCTION_RETURN_IGNORED", "__WARNING_DATETIME_MANIPULATION_FUNCTION_RETURN_IGNORED"]
+helpviewer_keywords: ["C26863"]
+---
+# Warning C26863
+
+> Return value from a date-time handling function `func` is ignored
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+It's important to verify the return value of a function that transforms a date structure when the year, month, or date input argument was manipulated without proper leap year handling. Otherwise, the function may have failed and execution continues with an output parameter containing invalid data.
+
+The following is a list of the functions that this warning covers:
+
+- [`FileTimeToSystemTime`](/windows/win32/api/timezoneapi/nf-timezoneapi-filetimetosystemtime)
+- [`SystemTimeToFileTime`](/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetofiletime)
+- [`SystemTimeToTzSpecificLocalTime`](/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetotzspecificlocaltime)
+- [`SystemTimeToTzSpecificLocalTimeEx`](/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetotzspecificlocaltimeex)
+- [`TzSpecificLocalTimeToSystemTime`](/windows/win32/api/timezoneapi/nf-timezoneapi-tzspecificlocaltimetosystemtime)
+- [`TzSpecificLocalTimeToSystemTimeEx`](/windows/win32/api/timezoneapi/nf-timezoneapi-tzspecificlocaltimetosystemtimeex)
+- [`RtlLocalTimeToSystemTime`](/windows/win32/api/winternl/nf-winternl-rtllocaltimetosystemtime)
+- [`RtlTimeToSecondsSince1970`](/windows/win32/api/winternl/nf-winternl-rtltimetosecondssince1970)
+
+Code analysis name: `DATETIME_MANIPULATION_FUNCTION_RETURN_IGNORED`
+
+## Example
+
+The following code tries to get current system time, advance the month field by one month, and get the file time that corresponds to the updated system time via [`SystemTimeToFileTime`](/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetofiletime). However, [`SystemTimeToFileTime`](/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetofiletime) might fail, as the updated system time may become invalid:
+
+```cpp
+#include
+
+void foo()
+{
+ FILETIME ft;
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+ st.wMonth++; // Advance month by one
+ // Get the file time
+ SystemTimeToFileTime(&st, &ft); // C26863
+}
+```
+
+To fix the problem, always check the return value from date-time manipulation functions and handle failures appropriately:
+
+```cpp
+#include
+
+void foo()
+{
+ FILETIME ft;
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+
+ st.wMonth++; // Advance month by one
+ // Get file time
+ if (SystemTimeToFileTime(&st, &ft))
+ {
+ // Use file time
+ }
+}
+```
+
+## Heuristics
+
+This rule only recognizes the Windows `SYSTEMTIME` struct and the C `tm` struct.
+
+This rule is enforced regardless of whether the input arguments were validated before calling these functions. If all the input arguments are validated before calling the function, this rule can report false warning.
+
+This rule is an opt-in rule, meaning that code analysis should use a ruleset file, and the rule should be explicitly included in the ruleset file, and enabled for it to be applied. For more information on creating a custom ruleset for code analysis, see [Use Rule Sets to Specify the `C++` Rules to Run](using-rule-sets-to-specify-the-cpp-rules-to-run.md).
+
+## See also
+
+[C6393](c6393.md)\
+[C6394](c6394.md)\
+[C26861](c26861.md)\
+[C26862](c26862.md)\
+[C26864](c26864.md)
diff --git a/docs/code-quality/c26864.md b/docs/code-quality/c26864.md
new file mode 100644
index 0000000000..0df5d94644
--- /dev/null
+++ b/docs/code-quality/c26864.md
@@ -0,0 +1,83 @@
+---
+description: "Learn more about: Warning C26864"
+title: Warning C26864
+ms.date: 11/29/2023
+f1_keywords: ["C26864", "DATETIME_MANIPULATION_ASSUMING_365_DAYS_WITHOUT_LEAPYEAR_CHECK", "__WARNING_DATETIME_MANIPULATION_ASSUMING_365_DAYS_WITHOUT_LEAPYEAR_CHECK"]
+helpviewer_keywords: ["C26864"]
+---
+# Warning C26864
+
+> Day field of a date-time object `var` has been modified assuming 365 days per year without proper leap year checking: `expr`
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+In the Gregorian calendar, every year exactly divisible by four is a leap year--except for years that are exactly divisible by 100. The centurial years are also leap years if they're exactly divisible by 400.
+
+A leap year bug occurs when software doesn't account for this leap year logic, or uses flawed logic. The can affect reliability, availability, or even the security of the affected system.
+
+You must take leap years into account when you perform arithmetic operations on a variable that represents a date. It's not safe to assume that a year is 365 days long. A leap year has 366 days because of the 'leap day' added as a 29th day in February.
+
+To correctly advance a year, determine whether the time span contains a leap day, then perform the calculation using the correct number of days. It's better if the year is directly advanced, with an appropriate leap day check on the resulting date. Alternatively, use an established library routine that handles leap years correctly.
+
+Code analysis name: `DATETIME_MANIPULATION_ASSUMING_365_DAYS_WITHOUT_LEAPYEAR_CHECK`
+
+## Example
+
+The following code tries to get current system time, advance the day by one year by adding 365 days to the day field, and adjusting the date per leap year rule. However, the result may not fall on the same month/date of the next year:
+
+```cpp
+#include
+
+void foo()
+{
+ SYSTEMTIME st;
+
+ GetSystemTime(&st);
+
+ // Advance a year by adding 365 days
+ st.wDay += 365; // C26864
+}
+```
+
+To fix this problem, advance the year field directly and adjust the date per the leap year rule:
+
+```cpp
+#include
+
+void foo()
+{
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+
+ st.wYear++; // Advance a year
+
+ // Adjust the date
+ if (st.wMonth == 2 && st.wDay == 29)
+ {
+ // Move back a day when landing on Feb 29 in a non-leap year
+ bool isLeapYear = st.wYear % 4 == 0 && (st.wYear % 100 != 0 || st.wYear % 400 == 0);
+ if (!isLeapYear)
+ {
+ st.wDay = 28;
+ }
+ }
+}
+```
+
+## Heuristics
+
+This rule only recognizes the Windows `SYSTEMTIME` struct and C `tm` struct.
+
+This rule is enforced if the date field is directly modified by 365 days. It doesn't consider if the value of date field is assigned to another variable and then manipulated, and so can miss equivalent mistakes.
+
+This rule is an opt-in rule, meaning that code analysis should use a ruleset file, and the rule should be explicitly included in the ruleset file, and enabled for it to be applied. For more information on creating a custom ruleset for code analysis, see [Use Rule Sets to Specify the `C++` Rules to Run](using-rule-sets-to-specify-the-cpp-rules-to-run.md).
+
+## See also
+
+[C6393](c6393.md)\
+[C6394](c6394.md)\
+[C26861](c26861.md)\
+[C26862](c26862.md)\
+[C26863](c26863.md)
diff --git a/docs/code-quality/c28020.md b/docs/code-quality/c28020.md
index d3597bd143..927e462bda 100644
--- a/docs/code-quality/c28020.md
+++ b/docs/code-quality/c28020.md
@@ -1,15 +1,32 @@
---
-description: "Learn more about: Warning C28020"
title: Warning C28020
-ms.date: 11/04/2016
+description: "Learn more about: Warning C28020"
+ms.date: 03/25/2025
f1_keywords: ["C28020"]
helpviewer_keywords: ["C28020"]
-ms.assetid: 3612185a-0858-4ba9-b795-4a0681073cf7
---
# Warning C28020
-> The expression '*expr*' is not true at this call
+> The expression '*expr*' is not true at this call.
This warning is reported when the `_Satisfies_` expression listed isn't true. Frequently, the warning indicates an incorrect parameter.
If this warning occurs on a function declaration, the annotations indicate an impossible condition.
+
+## Example
+
+The following example generates C28020:
+
+```cpp
+#include
+
+int func(_In_range_(0, 10) int value)
+{
+ return value;
+}
+
+int main()
+{
+ func(11); // C28020
+}
+```
diff --git a/docs/code-quality/c28112.md b/docs/code-quality/c28112.md
index 74c567f97d..530ab51bc0 100644
--- a/docs/code-quality/c28112.md
+++ b/docs/code-quality/c28112.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Warning C28112"
title: Warning C28112
+description: "Learn more about: Warning C28112"
ms.date: 08/25/2022
f1_keywords: ["C28112", "INTERLOCKED_ACCESS", "__WARNING_INTERLOCKED_ACCESS"]
helpviewer_keywords: ["C28112"]
-ms.assetid: 2720a5dc-84e9-4f78-a8c7-a320c9f9216b
---
# Warning C28112
@@ -16,7 +15,7 @@ A variable that is accessed by using the Interlocked executive support routines,
`InterlockedXxx` functions are intended to provide atomic operations, but are only atomic with respect to other `InterlockedXxx` functions. Although certain ordinary assignments, accesses, and comparisons to variables that are used by the Interlocked\* routines can be safely accessed by using a different function, the risk is great enough to justify examining each instance.
-Code analysis name: INTERLOCKED_ACCESS
+Code analysis name: `INTERLOCKED_ACCESS`
## Example
@@ -38,5 +37,5 @@ InterlockedIncrement(&inter_var);
## See Also
-[InterlockedIncrement function (wdm.h)](/windows-hardware/drivers/ddi/wdm/nf-wdm-interlockedincrement)
+[InterlockedIncrement function (wdm.h)](/windows-hardware/drivers/ddi/wdm/nf-wdm-interlockedincrement)\
[InterlockedDecrement function (wdm.h)](/windows-hardware/drivers/ddi/wdm/nf-wdm-interlockeddecrement)
diff --git a/docs/code-quality/c28159.md b/docs/code-quality/c28159.md
index e17a31ee6f..05fbe31944 100644
--- a/docs/code-quality/c28159.md
+++ b/docs/code-quality/c28159.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: Warning C28159"
title: Warning C28159
+description: "Learn more about: Warning C28159"
ms.date: 09/08/2022
f1_keywords: ["C28159", "USE_OTHER_FUNCTION", "__WARNING_USE_OTHER_FUNCTION"]
helpviewer_keywords: ["C28159"]
-ms.assetid: fab6cd58-0985-4ef6-89a2-64ed04297437
---
# Warning C28159
-> Consider using `*function_name_1*` instead of `*function_name_2*`. Reason: *reason*
+> Consider using *`function_name_1`* instead of *`function_name_2`*. Reason: *reason*
This warning occurs when you use a function that is semantically equivalent to an alternative, preferred function call.
@@ -16,7 +15,7 @@ This warning occurs when you use a function that is semantically equivalent to a
C28159 is a general warning message; the annotation `__drv_preferredFunction` was used (possibly with a conditional `__drv_when`() annotation) to flag a bad coding practice.
-Code analysis name: USE_OTHER_FUNCTION
+Code analysis name: `USE_OTHER_FUNCTION`
## Example
diff --git a/docs/code-quality/c28160.md b/docs/code-quality/c28160.md
index 38ea9be0b1..eeee7046da 100644
--- a/docs/code-quality/c28160.md
+++ b/docs/code-quality/c28160.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Warning C28160"
title: Warning C28160
+description: "Learn more about: Warning C28160"
ms.date: 09/08/2022
f1_keywords: ["C28160", "ERROR", "__WARNING_ERROR"]
helpviewer_keywords: ["C28160"]
-ms.assetid: cab15f6b-909c-4cc8-81a0-c24ac7c91c7c
---
# Warning C28160
@@ -16,4 +15,4 @@ This warning is reported when a `__drv_error` annotation has been encountered.
This annotation is used to flag coding practices that should be fixed, and can be used with a `__drv_when` annotation to indicate specific combinations of parameters.
-Code analysis name: ERROR
+Code analysis name: `ERROR`
diff --git a/docs/code-quality/c28196.md b/docs/code-quality/c28196.md
index e6f445f94c..388766230a 100644
--- a/docs/code-quality/c28196.md
+++ b/docs/code-quality/c28196.md
@@ -1,13 +1,53 @@
---
-description: "Learn more about: Warning C28196"
title: Warning C28196
+description: "Learn more about: Warning C28196"
ms.date: 11/04/2016
-f1_keywords: ["C28196"]
+f1_keywords: ["C28196", "RETURNING_BAD_RESULT", "__WARNING_RETURNING_BAD_RESULT"]
helpviewer_keywords: ["C28196"]
-ms.assetid: 5ee89e96-2796-4316-a64c-702463ca1374
---
# Warning C28196
> The requirement is not satisfied. (The expression does not evaluate to true.)
-This warning indicates that the function prototype for the function being analyzed has a `__notnull`, `__null` or `__drv_valueIs` on an `_Out_` parameter or the return value, but the value returned is inconsistent with that annotation.
+This warning indicates that the function being analyzed has a `__notnull`, `__null`, `__drv_valueIs` or similar annotation on an `_Out_` parameter or the return value, but the value returned is inconsistent with that annotation.
+
+## Remarks
+
+Annotations like `__notnull` describe invariants about `_Out_` parameters and return values, which serves both as documentation and as a sanity check for the author of the function. Warning C28196 indicates a mismatch between the annotations and the actual behavior of the function. The warning can be useful for discovering cases where a function might behave unexpectedly for certain input values. It's then up to the author to decide what the intended behavior of the function is and either adapt the annotations or the implementation accordingly.
+
+## Examples
+
+The following function causes warning C28196 because it's annotated with `_Ret_notnull_` even though some code paths return a null pointer.
+
+```cpp
+#include
+
+_Ret_notnull_
+Item *get_item(_In_reads_(len) Item *items, size_t len, size_t index) {
+ if (index >= len) {
+ return nullptr;
+ }
+
+ return items + index;
+}
+```
+
+To resolve this issue, refine the annotation to accurately reflect the function's behavior.
+
+```cpp
+#include
+
+_When_(index < len, _Ret_notnull_)
+Item *get_item(_In_reads_(len) Item *items, size_t len, size_t index) {
+ if (index >= len) {
+ return nullptr;
+ }
+
+ return items + index;
+}
+```
+
+## See also
+
+[Annotating function parameters and return values](./annotating-function-parameters-and-return-values.md)\
+[Specifying When and Where an Annotation Applies](./specifying-when-and-where-an-annotation-applies.md)
diff --git a/docs/code-quality/c28306.md b/docs/code-quality/c28306.md
index 6f1641b1a3..0462d5856d 100644
--- a/docs/code-quality/c28306.md
+++ b/docs/code-quality/c28306.md
@@ -11,3 +11,7 @@ ms.assetid: 64517b10-c8b3-4100-953b-278eab624369
> The annotation on parameter is obsolescent
Use `_String_length_` with the appropriate SAL2 annotation instead.
+
+## See also
+
+[Intrinsic Functions](./intrinsic-functions.md)
diff --git a/docs/code-quality/c28307.md b/docs/code-quality/c28307.md
index 672d1f5793..28d5af3d02 100644
--- a/docs/code-quality/c28307.md
+++ b/docs/code-quality/c28307.md
@@ -11,3 +11,7 @@ ms.assetid: e86a14cc-9ff1-4bad-9d85-93c739704ab8
> The annotation on parameter is obsolescent
Use `_String_length_` with the appropriate SAL2 annotation instead.
+
+## See also
+
+[Intrinsic Functions](./intrinsic-functions.md)
diff --git a/docs/code-quality/c28310.md b/docs/code-quality/c28310.md
index 4b85718201..30aa4d8244 100644
--- a/docs/code-quality/c28310.md
+++ b/docs/code-quality/c28310.md
@@ -1,9 +1,9 @@
---
-description: "Learn more about: Warning C28310"
title: Warning C28310
+description: "Learn more about: Warning C28310"
ms.date: 11/04/2016
f1_keywords: ["C28310"]
-ms.assetid: 51054ca8-01b6-454b-9853-f05f1c817b18
+helpviewer_keywords: ["C28310"]
---
# Warning C28310
diff --git a/docs/code-quality/c28311.md b/docs/code-quality/c28311.md
index 70e03e716e..9d72006cae 100644
--- a/docs/code-quality/c28311.md
+++ b/docs/code-quality/c28311.md
@@ -1,9 +1,9 @@
---
-description: "Learn more about: Warning C28311"
title: Warning C28311
+description: "Learn more about: Warning C28311"
ms.date: 11/04/2016
f1_keywords: ["C28311"]
-ms.assetid: 2c76e07a-4418-40ef-8a77-c62774bc3677
+helpviewer_keywords: ["C28311"]
---
# Warning C28311
diff --git a/docs/code-quality/c28312.md b/docs/code-quality/c28312.md
index 55f6154d54..852d5bec16 100644
--- a/docs/code-quality/c28312.md
+++ b/docs/code-quality/c28312.md
@@ -1,9 +1,9 @@
---
-description: "Learn more about: Warning C28312"
title: Warning C28312
+description: "Learn more about: Warning C28312"
ms.date: 11/04/2016
f1_keywords: ["C28312"]
-ms.assetid: 19828546-33c9-4373-b7df-2a362ca12637
+helpviewer_keywords: ["C28312"]
---
# Warning C28312
diff --git a/docs/code-quality/c33001.md b/docs/code-quality/c33001.md
index d3208941b4..679ffc1e04 100644
--- a/docs/code-quality/c33001.md
+++ b/docs/code-quality/c33001.md
@@ -13,14 +13,23 @@ helpviewer_keywords: ["C33001"]
## Remarks
-This warning is triggered when an uninitialized `VARIANT` is passed to an API such as `VariantClear`
-that expects an initialized `VARIANT`.
+This warning is triggered when an uninitialized `VARIANT` is passed to an API, such as `VariantClear`, that clears the object. Initialize the `VARIANT` before passing it to these functions so it can be properly cleared.
+
+This warning applies to these functions:
+
+* `VariantClear`
+* `PropVariantClear`
+* `VariantCopy`
+* `VariantCopyInd`
+* `VariantChangeType`
+* `VariantChangeTypeEx`
+* `DestroyPropVariant`
Code analysis name: `VARIANTCLEAR_UNINITIALIZED`
## Example
-The following sample code causes warning C33001:
+The following code causes warning C33001:
```cpp
#include
@@ -36,11 +45,11 @@ HRESULT foo(bool some_condition)
//...
}
- VariantClear(&var); // C33001
+ VariantClear(&var); // C33001
}
```
-These warnings are corrected by ensuring `VariantClear` is called only for a properly initialized `VARIANT`:
+In this example, the warning is corrected by calling `VariantClear` only after `var` has been initialized:
```cpp
#include
@@ -54,12 +63,12 @@ HRESULT foo(bool some_condition)
//...
VariantInit(&var);
//...
- VariantClear(&var); // C33001
+ VariantClear(&var); // OK
}
}
```
## See also
-[C33004](./c33004.md)
+[C33004](./c33004.md)\
[C33005](./c33005.md)
diff --git a/docs/code-quality/c33004.md b/docs/code-quality/c33004.md
index 752103c945..44486d8ffc 100644
--- a/docs/code-quality/c33004.md
+++ b/docs/code-quality/c33004.md
@@ -49,5 +49,5 @@ void t2(_Out_ VARIANT* pv)
## See also
-[C33001](./c33001.md)
+[C33001](./c33001.md)\
[C33005](./c33005.md)
diff --git a/docs/code-quality/c33005.md b/docs/code-quality/c33005.md
index 8c056ba671..41509513e3 100644
--- a/docs/code-quality/c33005.md
+++ b/docs/code-quality/c33005.md
@@ -55,5 +55,5 @@ void foo()
## See also
-[C33001](./c33001.md)
+[C33001](./c33001.md)\
[C33004](./c33004.md)
diff --git a/docs/code-quality/c33010.md b/docs/code-quality/c33010.md
index b9e5fa937d..e4c4a598df 100644
--- a/docs/code-quality/c33010.md
+++ b/docs/code-quality/c33010.md
@@ -9,7 +9,7 @@ helpviewer_keywords: ["C33010"]
---
# Warning C33010
-> Unchecked lower bound for enum *enum_name* used as index.
+> Unchecked lower bound for enum 'enum' used as index.
This warning is triggered if an enum is both used as an index into an array and isn't checked on the lower bound.
@@ -71,6 +71,31 @@ void foo(Index idx, PFN(&functions)[5])
}
```
+Alternatively, the issue can be fixed by choosing an underlying type for `Index` that is unsigned. Because an unsigned value is always positive, it is sufficient to only check the upper bound.
+
+```cpp
+typedef void (*PFN)();
+
+enum class Index : unsigned int
+{
+ Zero,
+ One,
+ Two,
+ Three,
+ Max
+};
+
+void foo(Index idx, PFN(&functions)[5])
+{
+ if (idx > Index::Max)
+ return;
+
+ auto pfn = functions[static_cast(idx)];
+ if (pfn != nullptr)
+ (*pfn)();
+}
+```
+
## See also
[C33011](./c33011.md)
diff --git a/docs/code-quality/c33011.md b/docs/code-quality/c33011.md
index f38913b3f2..f2087f89c8 100644
--- a/docs/code-quality/c33011.md
+++ b/docs/code-quality/c33011.md
@@ -4,7 +4,7 @@ description: C33011 warning for enums
author: hwisungi
ms.author: hwisungi
ms.date: 06/20/2020
-f1_keywords: ["C33011", "UNCHECKED_UPPER_BOUND_FOR_ENUMINDEX"]
+f1_keywords: ["C33011", "UNCHECKED_UPPER_BOUND_FOR_ENUMINDEX", "__WARNING_UNCHECKED_UPPER_BOUND_FOR_ENUMINDEX"]
helpviewer_keywords: ["C33011"]
---
# Warning C33011
diff --git a/docs/code-quality/c6001.md b/docs/code-quality/c6001.md
index 571cf38dfb..755bb88cb3 100644
--- a/docs/code-quality/c6001.md
+++ b/docs/code-quality/c6001.md
@@ -4,7 +4,6 @@ title: Warning C6001
ms.date: 10/04/2022
f1_keywords: ["C6001", "USING_UNINIT_VAR", "__WARNING_USING_UNINIT_VAR"]
helpviewer_keywords: ["C6001"]
-ms.assetid: 55e779f1-7295-48f7-8ce1-b43898b36cd8
---
# Warning C6001
@@ -18,7 +17,7 @@ Code analysis name: `USING_UNINIT_VAR`
## Example
-The following code generates this warning because variable `i` is only initialized if `b` is true; otherwise an uninitialized `i` is returned:
+The following code generates this warning because variable `i` is only initialized if `b` is true:
```cpp
int f( bool b )
@@ -37,7 +36,49 @@ To correct this warning, initialize the variable as shown in the following code:
```cpp
int f( bool b )
{
- int i= -1;
+ int i = -1;
+
+ if ( b )
+ {
+ i = 0;
+ }
+ return i;
+}
+```
+
+## Heuristics
+
+The following example shows that passing a variable to a function by reference causes the compiler to assume that it's initialized:
+
+```cpp
+void init( int& i );
+
+int f( bool b )
+{
+ int i;
+
+ init(i);
+
+ if ( b )
+ {
+ i = 0;
+ }
+ return i; // i is assumed to be initialized because it's passed by reference to init()
+}
+```
+
+This supports the pattern of passing a pointer to a variable into an initialization function.
+
+This heuristic can lead to false negatives because many functions expect pointers that point to initialized data. Use [SAL annotations](annotating-function-parameters-and-return-values.md), such as `_In_` and `_Out_`, to describe the function's behavior. The following example calls a function that expects its argument to be initialized, so a warning is generated:
+
+```cpp
+void use( _In_ int& i );
+
+int f( bool b )
+{
+ int i;
+
+ use(i); // uninitialized variable warning because of the _In_ annotation on use()
if ( b )
{
diff --git a/docs/code-quality/c6011.md b/docs/code-quality/c6011.md
index da1329fb26..2094f73796 100644
--- a/docs/code-quality/c6011.md
+++ b/docs/code-quality/c6011.md
@@ -64,6 +64,27 @@ void f([Pre(Null=Yes)] char* pc)
The careless use of `malloc` and `free` leads to memory leaks and exceptions. To minimize these kinds of leaks and exception problems altogether, avoid allocating raw memory yourself. Instead, use the mechanisms provided by the C++ Standard Library (STL). These include [`shared_ptr`](../standard-library/shared-ptr-class.md), [`unique_ptr`](../standard-library/unique-ptr-class.md), and [`vector`](../standard-library/vector.md). For more information, see [Smart Pointers](../cpp/smart-pointers-modern-cpp.md) and [C++ Standard Library](../standard-library/cpp-standard-library-reference.md).
+## Heuristics
+
+A heuristic used to reduce the number of warnings in legacy code assumes that a pointer is non-`NULL` unless there is evidence that it is `NULL`. In the examples we've seen so far, pointers returned by `malloc` or `new` might be `NULL` because allocation might fail. Another characteristic that the analysis engine uses as evidence of nullability is if the program explicitly checks for `NULL`. This is illustrated in the following examples:
+
+```cpp
+void f(int* n)
+{
+ *n = 1; // Does not warn, n is assumed to be non-null
+}
+
+void f(int* n)
+{
+ if (n) {
+ (*n)++;
+ }
+ *n = 1; // Warns because the earlier conditional shows that n might be null
+}
+```
+
+In the second case, the user can fix the warning by moving the `*n = 1` line inside the if block.
+
## See also
- [Using SAL Annotations to reduce code defects](using-sal-annotations-to-reduce-c-cpp-code-defects.md)
@@ -71,3 +92,5 @@ The careless use of `malloc` and `free` leads to memory leaks and exceptions. To
- [Indirection and Address-of Operators](../c-language/indirection-and-address-of-operators.md)
- [`malloc`](../c-runtime-library/reference/malloc.md)
- [`free`](../c-runtime-library/reference/free.md)
+- [`new` operator](../cpp/new-operator-cpp.md)
+- [`delete` operator](../cpp/delete-operator-cpp.md)
diff --git a/docs/code-quality/c6014.md b/docs/code-quality/c6014.md
index b950ef16b3..9806124fb8 100644
--- a/docs/code-quality/c6014.md
+++ b/docs/code-quality/c6014.md
@@ -97,7 +97,6 @@ const int TEST_DATA [ARRAYSIZE] = {10,20,30,40,50,60,70,80,90,100};
void f( )
{
-
unique_ptr p(new int[ARRAYSIZE]);
std::copy(begin(TEST_DATA), end(TEST_DATA), p.get());
diff --git a/docs/code-quality/c6029.md b/docs/code-quality/c6029.md
index 85829020b6..729f39ab08 100644
--- a/docs/code-quality/c6029.md
+++ b/docs/code-quality/c6029.md
@@ -1,6 +1,6 @@
---
-description: "Learn more about: Warning C6029"
title: Warning C6029
+description: "Learn more about: Warning C6029"
ms.date: 2/07/2023
f1_keywords: ["C6029", "USING_TAINTED_DATA", "__WARNING_USING_TAINTED_DATA"]
helpviewer_keywords: ["C6029"]
@@ -35,7 +35,7 @@ void processData(FILE* file)
}
```
-The fix for the issue depends on the nature of the data and the behavior of the annotated function that triggers the diagnostic. For more information, see the documentation for that function. A straightforward fix is to check the size before the second call to `std:fread`. In the next example, we throw an exception to terminate the function. Most real-world code would instead have an error recovery strategy that's specific to the scenario.
+The fix for the issue depends on the nature of the data and the behavior of the annotated function that triggers the diagnostic. For more information, see the documentation for that function. A straightforward fix is to check the size before the second call to `std::fread`. In the next example, we throw an exception to terminate the function. Most real-world code would instead have an error recovery strategy that's specific to the scenario.
```cpp
void processData(FILE* file)
@@ -55,7 +55,7 @@ void processData(FILE* file)
}
```
-In `std:fread` and similar functions, the code may need to read large amounts of data. To handle large data, you can allocate the size of the buffer dynamically after the size becomes known. Or, you can call `std:fread` multiple times as needed to read in the rest of the data. If you allocate the buffer dynamically, we recommend you put a limit on the size to avoid introducing an out-of-memory exploit for large values. We don't use this approach in our example because it's already bounded by the size of `uint8_t`.
+In `std::fread` and similar functions, the code may need to read large amounts of data. To handle large data, you can allocate the size of the buffer dynamically after the size becomes known. Or, you can call `std::fread` multiple times as needed to read in the rest of the data. If you allocate the buffer dynamically, we recommend you put a limit on the size to avoid introducing an out-of-memory exploit for large values. We don't use this approach in our example because it's already bounded by the size of `uint8_t`.
```cpp
void processDataDynamic(FILE* file)
diff --git a/docs/code-quality/c6030.md b/docs/code-quality/c6030.md
index 41d536acb3..d839858cfa 100644
--- a/docs/code-quality/c6030.md
+++ b/docs/code-quality/c6030.md
@@ -6,17 +6,18 @@ f1_keywords: ["C6030", "USE_ATTRIBUTE_NORETURN", "__WARNING_USE_ATTRIBUTE_NORETU
helpviewer_keywords: ["C6030"]
---
-# Warning C6030
+# Warning C6030
> Use attribute [[noreturn]] over __declspec(noreturn) in function '*function-name*'
## Remarks
-This warning suggests using the C++11 standard attribute `[[noreturn]]` in place of the declspec variant `__declspec(noreturn)`. The standard attribute provides better cross-platform support because it doesn't rely on language extensions.
+This warning suggests using the C++11 standard attribute [`[[noreturn]]`](../cpp/attributes.md#noreturn) in place of the declspec variant [`__declspec(noreturn)`](../cpp/noreturn.md). The standard attribute provides better cross-platform support because it doesn't rely on language extensions.
This warning is off by default and isn't part of the `All Rules` rule set. To enable this warning, it must be added to the rule set file being used.
This check is available in Visual Studio 2022 version 17.0 and later versions.
+
Code analysis name: `USE_ATTRIBUTE_NORETURN`
## Example
@@ -24,15 +25,13 @@ Code analysis name: `USE_ATTRIBUTE_NORETURN`
The following code generates C6030:
```cpp
-__declspec(noreturn) void TerminateApplication();
-
+__declspec(noreturn) void terminate_application();
```
Fix the issue by using the `[[noreturn]]` attribute:
```cpp
-[[ noreturn ]] void TerminateApplication();
-
+[[noreturn]] void terminate_application();
```
## See also
diff --git a/docs/code-quality/c6031.md b/docs/code-quality/c6031.md
index 5a6627f664..541fca4ba5 100644
--- a/docs/code-quality/c6031.md
+++ b/docs/code-quality/c6031.md
@@ -1,10 +1,9 @@
---
title: Warning C6031
description: "Describes C++ Code Analysis warning C6031 and how to resolve it."
-ms.date: 10/04/2022
+ms.date: 4/5/2024
f1_keywords: ["C6031", "RETVAL_IGNORED_FUNC_COULD_FAIL", "__WARNING_RETVAL_IGNORED_FUNC_COULD_FAIL"]
helpviewer_keywords: ["C6031"]
-ms.assetid: 59e1ef0a-b3ca-4ffa-bcb3-ad2bd22ece22
---
# Warning C6031
@@ -16,44 +15,48 @@ Warning C6031 indicates the caller doesn't check a function's return value for f
In general, it isn't safe to assume that calls to functions requiring disk, network, memory, or other resources will succeed. The caller should always check the return value and handle error cases appropriately. Also consider using the `_Must_inspect_result_` annotation, which checks that the value is examined in a useful way.
+This warning applies to both C and C++ code.
+
Code analysis name: `RETVAL_IGNORED_FUNC_COULD_FAIL`
## Example
The following code generates warning C6031:
-```cpp
+```c
#include
-void f( )
+int main()
{
- fopen( "test.c", "r" ); // C4996, C6031 return value ignored
+ fopen("test.c", "r"); // C4996, C6031 return value ignored
// code ...
}
```
To correct this warning, check the return value of the function as shown in the following code:
-```cpp
+```c
#include
-void f( )
+int main()
{
- FILE *stream;
- if ( (stream = fopen( "test.c", "r" )) == NULL )
+ FILE* stream;
+ if ((stream = fopen("test.c", "r")) == NULL)
+ {
return;
+ }
// code ...
}
```
The following code uses safe function `fopen_s` to correct this warning:
-```cpp
+```c
#include
-void f( )
+int main()
{
- FILE *stream;
+ FILE* stream;
errno_t err;
- if ( (err = fopen_s( &stream, "test.c", "r" )) !=0 )
+ if ((err = fopen_s(&stream, "test.c", "r")) != 0)
{
// code ...
}
@@ -64,11 +67,14 @@ This warning is also generated if the caller ignores the return value of a funct
```cpp
#include
-_Check_return_ bool func();
+_Check_return_ bool func()
+{
+ return true;
+}
-void test_f()
+int main()
{
- func(); // Warning C6031
+ func();
}
```
@@ -76,11 +82,15 @@ To correct the previous warning, check the return value as shown in the followin
```cpp
#include
-_Check_return_ bool func();
+_Check_return_ bool func()
+{
+ return true;
+}
-void test_f()
+int main()
{
- if ( func() ) {
+ if (func())
+ {
// code ...
}
}
@@ -91,10 +101,12 @@ In cases where it's necessary to ignore the return value of a function, assign t
```cpp
#include
#include
+#include
#include
-void f()
+
+int main()
{
- std::srand(static_cast(std::time(nullptr))); // set initial seed value to system clock
+ std::srand(static_cast(std::time(nullptr))); // set initial seed value to system clock
std::ignore = std::rand(); // Discard the first result as the few random results are always small.
// ...
}
diff --git a/docs/code-quality/c6053.md b/docs/code-quality/c6053.md
index 06943ee97c..426980c787 100644
--- a/docs/code-quality/c6053.md
+++ b/docs/code-quality/c6053.md
@@ -69,7 +69,9 @@ size_t f( )
}
```
-You should note that this warning is sometimes reported on certain idioms guaranteed to be safe in practice. Because of the frequency and potential consequences of this defect, the analysis tool is biased in favor of finding potential issues instead of its typical bias of reducing noise.
+## Heuristics
+
+This warning is sometimes reported on certain idioms guaranteed to be safe in practice. Because of the frequency and potential consequences of this defect, the analysis tool is biased in favor of finding potential issues instead of its typical bias of reducing noise.
## See also
diff --git a/docs/code-quality/c6059.md b/docs/code-quality/c6059.md
index 8a12022eb0..d78c0f3f74 100644
--- a/docs/code-quality/c6059.md
+++ b/docs/code-quality/c6059.md
@@ -1,7 +1,7 @@
---
description: "Learn more about: Warning C6059"
title: Warning C6059
-ms.date: 10/04/2022
+ms.date: 12/14/2023
f1_keywords: ["C6059", "BAD_CONCATENATION", "__WARNING_BAD_CONCATENATION"]
helpviewer_keywords: ["C6059"]
ms.assetid: 343a4cd1-048a-4edf-bb4b-187097bb6093
@@ -14,6 +14,8 @@ ms.assetid: 343a4cd1-048a-4edf-bb4b-187097bb6093
This warning indicates that a call to a string concatenation function is probably passing an incorrect value for the number of characters to concatenate. This defect might cause an exploitable buffer overrun or crash. A common cause of this defect is passing the buffer size (instead of the remaining number of characters in the buffer) to the string manipulation function.
+This warning helps identify the common error of sending the size of the target buffer instead of the size of the data. It does so by detecting when the size used to allocate the buffer is passed, unchanged, to the function putting data in the buffer.
+
Code analysis name: `BAD_CONCATENATION`
## Example
@@ -27,8 +29,8 @@ The following code generates warning C6059:
void f( )
{
char szTarget[MAX];
- char *szState ="Washington";
- char *szCity="Redmond, ";
+ const char *szState ="Washington";
+ const char *szCity="Redmond, ";
strncpy(szTarget, szCity, MAX);
szTarget[MAX -1] = '\0';
@@ -46,8 +48,8 @@ To correct this warning, use the correct number of characters to concatenate as
void f( )
{
char szTarget[MAX];
- char *szState ="Washington";
- char *szCity="Redmond, ";
+ const char *szState ="Washington";
+ const char *szCity="Redmond, ";
strncpy(szTarget, szCity, MAX);
szTarget[MAX -1] = '\0';
@@ -63,8 +65,8 @@ To correct this warning using the safe string manipulation functions `strncpy_s`
void f( )
{
- char *szState ="Washington";
- char *szCity="Redmond, ";
+ const char *szState ="Washington";
+ const char *szCity="Redmond, ";
size_t nTargetSize = strlen(szState) + strlen(szCity) + 1;
char *szTarget= new char[nTargetSize];
@@ -77,6 +79,48 @@ void f( )
}
```
+## Heuristics
+
+This analysis detects when the target buffer size is passed unmodified into the length parameter of the string manipulation function. This warning isn't given if some other value is passed as the length parameter, even if that value is incorrect.
+
+Consider the following code that generates warning C6059:
+
+```cpp
+#include
+#define MAX 25
+
+void f( )
+{
+ char szTarget[MAX];
+ const char *szState ="Washington";
+ const char *szCity="Redmond, ";
+
+ strncpy(szTarget, szCity, MAX);
+ szTarget[MAX -1] = '\0';
+ strncat(szTarget, szState, MAX); // wrong size
+ // code ...
+}
+```
+
+The warning goes away by changing the `MAX` argument to `strncat` to `MAX - 1`, even though the length calculation is still incorrect.
+
+```cpp
+#include
+#define MAX 25
+
+void f( )
+{
+ char szTarget[MAX];
+ const char *szState ="Washington";
+ const char *szCity="Redmond, ";
+
+ strncpy(szTarget, szCity, MAX);
+ szTarget[MAX -1] = '\0';
+ strncat(szTarget, szState, MAX - 1); // wrong size, but no warning
+ // code ...
+}
+```
+
## See also
- [`strncpy_s`, `_strncpy_s_l`, `wcsncpy_s`, `_wcsncpy_s_l`, `_mbsncpy_s`, `_mbsncpy_s_l`](../c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md)
diff --git a/docs/code-quality/c6102.md b/docs/code-quality/c6102.md
index d1dd840a69..9c35f2bc5a 100644
--- a/docs/code-quality/c6102.md
+++ b/docs/code-quality/c6102.md
@@ -1,9 +1,9 @@
---
-description: "Learn more about: Warning C6102"
title: Warning C6102
+description: "Learn more about: Warning C6102"
ms.date: 11/04/2016
f1_keywords: ["C6102"]
-ms.assetid: cfd49a8c-df46-48de-8dcb-02ecf2450034
+helpviewer_keywords: ["C6102"]
---
# Warning C6102
diff --git a/docs/code-quality/c6103.md b/docs/code-quality/c6103.md
index d348b72bd5..6c9dfdcfcd 100644
--- a/docs/code-quality/c6103.md
+++ b/docs/code-quality/c6103.md
@@ -1,9 +1,9 @@
---
-description: "Learn more about: Warning C6103"
title: Warning C6103
+description: "Learn more about: Warning C6103"
ms.date: 11/04/2016
f1_keywords: ["C6103"]
-ms.assetid: 22d1ab35-31a3-4ba9-8ef4-7a64bce66621
+helpviewer_keywords: ["C6103"]
---
# Warning C6103
diff --git a/docs/code-quality/c6200.md b/docs/code-quality/c6200.md
index 8c2ddee479..2106582d1a 100644
--- a/docs/code-quality/c6200.md
+++ b/docs/code-quality/c6200.md
@@ -8,9 +8,9 @@ ms.assetid: bbeb159b-4e97-4317-9a07-bb83cd03069a
---
# Warning C6200
-> Index '*index*' is out of valid index range '*min*' to '*max*' for non-stack buffer '*parameter-name*'
+> Index '*index*' is out of valid index range '*min*' to '*max*' for nonstack buffer '*parameter-name*'
-This warning indicates that an integer offset into the specified non-stack array exceeds the maximum bounds of that array, potentially causing random behavior and/or crashes.
+This warning indicates that an integer offset into the specified nonstack array exceeds the maximum bounds of that array, causing undefined behavior and potentially crashes.
## Remarks
@@ -47,3 +47,27 @@ void f()
delete[] buff;
}
```
+
+## Heuristics
+
+Code analysis can't always prove whether an array index is in range. This can happen, for example, when the index is computed from a complex expression, including those expressions that call into other functions. In these cases, code analysis may fall back on other clues to determine the range an array index expression may fall into.
+
+For example, consider the following function that uses `rand()` in index calculations as a stand-in for a function call that code analysis can't analyze:
+
+```cpp
+#include
+
+void f()
+{
+ int* buff = new int[14];
+ for (int i = 1; i < 14; i++)
+ {
+ buff[rand()] = 0; // no warning, nothing is known about the return value of rand()
+ buff[rand() % 15] = 0; // warning C6200, rand() % 15 is known to be in the range 0..14 and index 14 is out of bounds
+ buff[rand() % 14] = 0; // no warning, rand() % 14 is known to be in the range 0..13
+ }
+ delete[] buff;
+}
+```
+
+Code analysis doesn't warn with just `rand()` because it doesn't have any information about its return value. On the other hand, `rand() % 15` and `rand() % 14` provide hints as to the range of the return value of `rand()` and code analysis can use that information to determine that the index is out of bounds in the first case but not the second.
diff --git a/docs/code-quality/c6201.md b/docs/code-quality/c6201.md
index 30ca1e6f2f..85118a0503 100644
--- a/docs/code-quality/c6201.md
+++ b/docs/code-quality/c6201.md
@@ -1,16 +1,15 @@
---
description: "Learn more about: Warning C6201"
title: Warning C6201
-ms.date: 09/28/2022
+ms.date: 11/17/2023
f1_keywords: ["C6201", "INDEX_EXCEEDS_MAX", "__WARNING_INDEX_EXCEEDS_MAX"]
helpviewer_keywords: ["C6201"]
-ms.assetid: eefbbd77-007c-4f28-95f6-6de5ee6a27db
---
# Warning C6201
> Index '*index-name*' is out of valid index range '*minimum*' to '*maximum*' for possibly stack allocated buffer '*variable*'
-This warning indicates that an integer offset into the specified stack array exceeds the maximum bounds of that array. It may potentially cause stack overflow errors, random behavior, or crashes.
+This warning indicates that an integer offset into the specified stack array exceeds the maximum bounds of that array. It might potentially cause stack overflow errors, undefined behavior, or crashes.
## Remarks
@@ -45,3 +44,9 @@ void f()
}
}
```
+
+## Heuristics
+
+This analysis is limited to stack-allocated arrays. It doesn't consider, for example, arrays passed into the function with a Microsoft source code annotation language ([SAL](understanding-sal.md))-annotated length.
+
+This analysis can't catch all possible out of bounds indices because not all arithmetic can be precisely analyzed. It's tuned to report cases where it can guarantee an out of bounds index is possible. The absence of a warning doesn't mean the index is guaranteed to be in bounds.
diff --git a/docs/code-quality/c6240.md b/docs/code-quality/c6240.md
index d50c2ba072..1e44d46db2 100644
--- a/docs/code-quality/c6240.md
+++ b/docs/code-quality/c6240.md
@@ -53,7 +53,7 @@ void f(int n)
}
else
{
- puts("bitmak false");
+ puts("bitmask false");
}
}
```
diff --git a/docs/code-quality/c6296.md b/docs/code-quality/c6296.md
index c5b5b21acb..e6f7da0340 100644
--- a/docs/code-quality/c6296.md
+++ b/docs/code-quality/c6296.md
@@ -1,47 +1,35 @@
---
-description: "Learn more about: Warning C6296"
title: Warning C6296
-ms.date: 11/04/2016
+description: "Learn more about: Warning C6296"
+ms.date: 03/30/2025
f1_keywords: ["C6296", "LOOP_ONLY_EXECUTED_ONCE", "__WARNING_LOOP_ONLY_EXECUTED_ONCE"]
helpviewer_keywords: ["C6296"]
-ms.assetid: 226573e0-db18-4c44-8fc6-0bc09d1028bc
---
# Warning C6296
-> Ill-defined for-loop: Loop body only executed once
+> Ill-defined for-loop. Loop body only executed once.
## Remarks
-This warning indicates that a for-loop might not function as intended. When the index is unsigned and a loop counts down from zero, its body is run only once.
+This warning indicates that a for-loop might unintentionally execute only once. A loop with an unsigned index counting down from zero or a mistaken use of `==` might cause this warning.
Code analysis name: `LOOP_ONLY_EXECUTED_ONCE`
## Example
-The following code generates this warning:
+The following example generates C6296. Each for-loop shown executes exactly once.
```cpp
-void f( )
+int main()
{
- unsigned int i;
+ for (unsigned int i = 0; i < 10; i--) {} // C6296
+ // Use the following line to resolve the warning:
+ // for (unsigned int i = 0; i < 10; i++) {}
- for (i = 0; i < 100; i--)
- {
- // code ...
- }
-}
-```
+ for (int i = 0; i == 0; i++) {} // C6296
-To correct this warning, use the following code:
-
-```cpp
-void f( )
-{
- unsigned int i;
+ for (int i = 0; i < 1; i++) {} // OK
- for (i = 0; i < 100; i++)
- {
- // code ...
- }
+ for (int i = 1; i > 0; i--) {} // OK
}
```
diff --git a/docs/code-quality/c6328.md b/docs/code-quality/c6328.md
index 76eb97a120..87bb1426d8 100644
--- a/docs/code-quality/c6328.md
+++ b/docs/code-quality/c6328.md
@@ -1,41 +1,66 @@
---
description: "Learn more about: Warning C6328"
title: Warning C6328
-ms.date: 09/15/2022
+ms.date: 02/14/2024
f1_keywords: ["C6328", "FORMAT_SIZE_MISMATCH", "__WARNING_FORMAT_SIZE_MISMATCH"]
helpviewer_keywords: ["C6328"]
ms.assetid: e25b00fa-d344-4dc9-b322-b4f1ae06f315
---
# Warning C6328
-> Size mismatch: '*type*' passed as parameter '*number*' when '*type*' is required in call to '*function-name*'
+> Size mismatch: '*type*' passed as _Param_(*number*) when '*type*' is required in call to '*function-name*'
## Remarks
-An argument of type `char` passed to C runtime, character-based routines named `is` (for example, `isspace`) can have unpredictable results. For example, an SBCS or MBCS single-byte character of type `char` with a value greater than `0x7F` is a negative value. If a `char` is passed, the compiler might convert the value to a signed `int` or a signed `long`. This value could be sign-extended by the compiler, with unexpected results. This issue could result in a function like `isspace`, which only expects values from 0-255 or `EOF`, being sent a negative value.
-
-Warning C6328 exists specifically to catch this bug. For characters in the 7-bit ASCII range, the cast is unnecessary. Characters outside that range can have unpredictable results such as program fault and termination.
+This warning indicates that type required by the format specifier and the type of the expression passed in don't match.
+Using the wrong format specifier is undefined behavior. To fix the warning, make sure that the format specifiers match the types of the expressions passed in.
Code analysis name: `FORMAT_SIZE_MISMATCH`
## Example
-The following code generates this warning. By default, `char` is a signed type in the Microsoft C++ compiler, so the range of values of a `char` is -128 to 127. Therefore, in the following code, `c` would be sign-extended to a signed `int` with a value of -37, which is outside the valid range for [isspace](../standard-library/locale-functions.md#isspace):
+```cpp
+#include
+
+void f(long long a)
+{
+ printf("%d\n", a); // C6328 emitted.
+}
+```
+
+There are multiple ways to fix the undefined behavior. We can change the format specifier:
+
+```cpp
+#include
+
+void f(long long a)
+{
+ printf("%lld\n", a); // No C6328 emitted.
+}
+```
+
+We can change the type of the expression:
```cpp
-void f()
+#include
+
+void f(int a)
{
- char c = -37;
- int retVal = isspace(c);
+ printf("%d\n", a); // No C6328 emitted.
}
```
-The following code remediates this warning by using `static_cast`:
+As a last resort when overflow can't happen, we can introduce a cast:
```cpp
-void f( )
+#include
+
+void f(unsigned char a)
{
- char c = -37;
- int retVal = isspace(static_cast(c));
+ printf("%hhd\n", static_cast(a)); // No C6328 emitted.
}
```
+
+## See also
+
+[C6340](c6340.md)
diff --git a/docs/code-quality/c6331.md b/docs/code-quality/c6331.md
index 8c3047f9cd..b0e322a1d4 100644
--- a/docs/code-quality/c6331.md
+++ b/docs/code-quality/c6331.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: Warning C6331"
title: Warning C6331
+description: "Learn more about: Warning C6331"
ms.date: 10/03/2022
f1_keywords: ["C6331", "VirtualFreeInvalidParam1", "__WARNING_VIRTUALFREEINVALIDPARAM1"]
helpviewer_keywords: ["C6331"]
-ms.assetid: cb1ecc2c-29a5-4c57-acf2-0954a4c047b1
---
# Warning C6331
-> Invalid parameter: passing MEM_RELEASE and MEM_DECOMMIT in conjunction to `*function*` is not allowed. This results in the failure of this call
+> Invalid parameter: passing MEM_RELEASE and MEM_DECOMMIT in conjunction to *`function`* is not allowed. This results in the failure of this call
This message indicates that an invalid parameter is passed to `VirtualFree` or `VirtualFreeEx`. `VirtualFree` and `VirtualFreeEx` both reject the flags (`MEM_RELEASE | MEM_DECOMMIT`) in combination. Therefore, the values `MEM_DECOMMIT` and `MEM_RELEASE` may not be used together in the same call.
diff --git a/docs/code-quality/c6335.md b/docs/code-quality/c6335.md
index 738a51f131..a5f62fe5fe 100644
--- a/docs/code-quality/c6335.md
+++ b/docs/code-quality/c6335.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Warning C6335"
title: Warning C6335
+description: "Learn more about: Warning C6335"
ms.date: 11/04/2016
f1_keywords: ["C6335", "LEAKING_PROCESS_HANDLE", "__WARNING_LEAKING_PROCESS_HANDLE"]
helpviewer_keywords: ["C6335"]
-ms.assetid: f81c0859-3d82-4182-8bf1-6c3b76c7486f
---
# Warning C6335
@@ -54,7 +53,7 @@ void f( )
}
```
-To correct this warning, call `CloseHandle (pi.``hThread)` to close thread handle as shown in the following code:
+To correct this warning, call `CloseHandle( pi.hThread )` to close thread handle as shown in the following code:
```cpp
#include
diff --git a/docs/code-quality/c6340.md b/docs/code-quality/c6340.md
index 90c235edc5..baf564d026 100644
--- a/docs/code-quality/c6340.md
+++ b/docs/code-quality/c6340.md
@@ -1,11 +1,67 @@
---
description: "Learn more about: Warning C6340"
title: Warning C6340
-ms.date: 11/04/2016
-f1_keywords: ["C6340"]
+ms.date: 02/14/2024
+f1_keywords: ["C6340", "FORMAT_SIGN_MISMATCH"]
helpviewer_keywords: ["C6340"]
ms.assetid: c4fe474f-5a27-4148-ba35-1ef021371e13
---
# Warning C6340
-> Mismatch on sign: Incorrect type passed as parameter in call to function
+> Mismatch on sign: '*type*' passed as _Param_(*number*) when some (signed|unsigned) type is required in call to '*function-name*'
+
+## Remarks
+
+This warning indicates that sign of the type required by the format specifier and sign of the type of the expression passed in don't match.
+Using the wrong format specifier is undefined behavior. To fix the warning, make sure that the format specifiers match the types of the expressions passed in.
+
+Code analysis name: `FORMAT_SIGN_MISMATCH`
+
+## Example
+
+```cpp
+#include
+
+void f(unsigned char a)
+{
+ printf("%hhd\n", a); // C6340 emitted.
+}
+```
+There are multiple ways to fix the undefined behavior. We can change the format specifier:
+
+```cpp
+#include
+
+void f(unsigned char a)
+{
+ printf("%hhu\n", a); // No C6340 emitted.
+}
+```
+
+We can change the type of the expression:
+
+```cpp
+#include
+
+void f(signed char a)
+{
+ printf("%hhd\n", a); // No C6340 emitted.
+}
+```
+
+As a last resort when overflow can't happen, we can introduce a cast:
+
+```cpp
+#include
+
+void f(long long a)
+{
+ printf("%d\n", static_cast(a)); // No C6328 emitted.
+}
+```
+
+## See also
+
+[C6328](c6328.md)
+
+
diff --git a/docs/code-quality/c6383.md b/docs/code-quality/c6383.md
index 84bf8c2737..72d0ef8b4f 100644
--- a/docs/code-quality/c6383.md
+++ b/docs/code-quality/c6383.md
@@ -1,14 +1,13 @@
---
-description: "Learn more about: Warning C6383"
title: Warning C6383
+description: "Learn more about: Warning C6383"
ms.date: 09/07/2022
f1_keywords: ["C6383", "ELEMENTS_TO_BYTES", "__WARNING_ELEMENTS_TO_BYTES"]
helpviewer_keywords: ["C6383"]
-ms.assetid: f5ff7938-0fbe-4b71-b98f-098fe887799d
---
# Warning C6383
-> Buffer overrun due to conversion of an element count into a byte count: an element count is expected for parameter `*parameter_name*` in call to `*function_name*`
+> Buffer overrun due to conversion of an element count into a byte count: an element count is expected for parameter *`parameter_name`* in call to *`function_name`*
This warning indicates that a non-constant byte count is being passed when an element count is instead required.
diff --git a/docs/code-quality/c6386.md b/docs/code-quality/c6386.md
index 2419833b70..7aa56f9f9f 100644
--- a/docs/code-quality/c6386.md
+++ b/docs/code-quality/c6386.md
@@ -1,10 +1,9 @@
---
description: "Learn more about: Warning C6386"
title: Warning C6386
-ms.date: 11/04/2016
+ms.date: 4/30/2025
f1_keywords: ["C6386", "WRITE_OVERRUN", "__WARNING_WRITE_OVERRUN"]
helpviewer_keywords: ["C6386"]
-ms.assetid: 84e69fe8-8f03-4bb3-b194-e5551882e214
---
# Warning C6386
@@ -23,15 +22,14 @@ The following code generates both this warning and [C6201](../code-quality/c6201
```cpp
#define MAX 25
-void f ( )
+void f()
{
- char ar[MAX];
- // code ...
- ar[MAX] = '\0';
+ char a[MAX];
+ a[MAX] = '\0'; // this writes one element past the end of the buffer
}
```
-To correct both warnings, use the following code:
+To correct the warning, use the following code which accounts for the fact that array indexes are zero-based. Thus `MAX - 1` is the last element in the buffer:
```cpp
#define MAX 25
@@ -39,8 +37,7 @@ To correct both warnings, use the following code:
void f ( )
{
char a[MAX];
- // code ...
- a[MAX - 1] = '\0';
+ a[MAX-1] = '\0';
}
```
diff --git a/docs/code-quality/c6387.md b/docs/code-quality/c6387.md
index d96f377b6d..a925d0b397 100644
--- a/docs/code-quality/c6387.md
+++ b/docs/code-quality/c6387.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Warning C6387"
title: Warning C6387
+description: "Learn more about: Warning C6387"
ms.date: 11/04/2016
f1_keywords: ["C6387", "INVALID_PARAM_VALUE_1", "__WARNING_INVALID_PARAM_VALUE_1"]
helpviewer_keywords: ["C6387"]
-ms.assetid: 3ea2fc4d-ffc3-4c3c-bfae-d42aa56235d8
---
# Warning C6387
@@ -27,7 +26,7 @@ _Post_ _Null_ char * g();
void f(_In_ char *pch);
-void main()
+int main()
{
char *pCh = g();
f(pCh); // Warning C6387
@@ -43,7 +42,7 @@ _Post_ _Notnull_ char * g();
void f(_In_ char *pch);
-void main()
+int main()
{
char *pCh = g();
f(pCh);
diff --git a/docs/code-quality/c6392.md b/docs/code-quality/c6392.md
new file mode 100644
index 0000000000..b8dc3b2ff4
--- /dev/null
+++ b/docs/code-quality/c6392.md
@@ -0,0 +1,60 @@
+---
+description: "Learn more about: Warning C6392"
+title: Warning C6392
+ms.date: 03/06/2024
+f1_keywords: ["C6392", "STREAM_OUTPUT_VOID_PTR", "__STREAM_OUTPUT_VOID_PTR"]
+helpviewer_keywords: ["C6392"]
+---
+# Warning C6392
+
+> This expression writes the value of the pointer to the stream. If this is intentional, add an explicit cast to 'void *'
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+C++ supports wide character streams such as `std::wostringstream`, and nonwide character streams such as `std::ostringstream`. Trying to print a wide string to a nonwide stream calls the `void*` overload of `operator<<`. This overload prints the address of the wide string instead of the value.
+
+Code analysis name: `STREAM_OUTPUT_VOID_PTR`
+
+## Example
+
+The following code snippet prints the value of the pointer to the standard output instead of the string `"Pear"`:
+
+```cpp
+#include
+
+int main() {
+ std::cout << L"Pear\n"; // Warning: C6392
+}
+```
+
+There are multiple ways to fix this error. If printing the pointer value is unintended, use a nonwide string:
+
+```cpp
+#include
+
+int main() {
+ std::cout << "Pear\n"; // No warning.
+}
+```
+
+Alternatively, use a wide stream:
+
+```cpp
+#include
+
+int main() {
+ std::wcout << L"Pear\n"; // No warning.
+}
+```
+
+If the behavior is intentional, make the intention explicit and silence the warning by using an explicit cast:
+
+```cpp
+#include
+
+int main() {
+ std::cout << static_cast(L"Pear\n"); // No warning.
+}
+```
diff --git a/docs/code-quality/c6393.md b/docs/code-quality/c6393.md
new file mode 100644
index 0000000000..a905c012a2
--- /dev/null
+++ b/docs/code-quality/c6393.md
@@ -0,0 +1,61 @@
+---
+title: Warning C6393
+description: "Learn more about: Warning C6393"
+ms.date: 11/29/2023
+f1_keywords: ["C6393", "LEAP_YEAR_INVALID_DATE_KEYED_LOOKUP", "__WARNING_LEAP_YEAR_INVALID_DATE_KEYED_LOOKUP"]
+helpviewer_keywords: ["C6393"]
+---
+# Warning C6393
+
+> A lookup table of size 365 isn't sufficient to handle leap years
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+In the Gregorian calendar, every year exactly divisible by four is a leap year--except for years that are exactly divisible by 100. The centurial years are also leap years if they're exactly divisible by 400.
+
+A leap year bug occurs when software doesn't account for this leap year logic, or uses flawed logic. The can affect reliability, availability, or even the security of the affected system.
+
+Lookup tables of size 365 are often used to quickly find the month a given day corresponds to. However, it isn't correct because a leap year has 366 days.
+
+Code analysis name: `LEAP_YEAR_INVALID_DATE_KEYED_LOOKUP`
+
+## Example
+
+The following code creates a lookup table for the day of the year, assuming 365 days per year. However, this doesn't work if the year is a leap year:
+
+```cpp
+#include
+
+void foo(int year)
+{
+ const std::vector items(365); // C6393
+ // Initialize items and use it...
+}
+```
+
+To fix the problem, adjust the size of the lookup table as the table is created according to the result of appropriate leap year check:
+
+```cpp
+#include
+
+void foo(int year)
+{
+ bool isLeapYear = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
+ const std::vector items(isLeapYear ? 366 : 365);
+ // Initialize items and use it...
+}
+```
+
+## Heuristics
+
+This rule is enforced by checking if a constant lookup table is sized for 365 elements. Violation of this rule causes a high confidence warning to be reported.
+
+## See also
+
+[C6394](c6394.md)\
+[C26861](c26861.md)\
+[C26862](c26862.md)\
+[C26863](c26863.md)\
+[C26864](c26864.md)
diff --git a/docs/code-quality/c6394.md b/docs/code-quality/c6394.md
new file mode 100644
index 0000000000..d4a4fe6668
--- /dev/null
+++ b/docs/code-quality/c6394.md
@@ -0,0 +1,63 @@
+---
+title: Warning C6394
+description: "Learn more about: Warning C6394"
+ms.date: 11/29/2023
+f1_keywords: ["C6394", "LEAP_YEAR_INVALID_DATE_KEYED_LOOKUP_MUTABLE", "__WARNING_LEAP_YEAR_INVALID_DATE_KEYED_LOOKUP_MUTABLE"]
+helpviewer_keywords: ["C6394"]
+---
+# Warning C6394
+
+> A lookup table of size 365 isn't sufficient to handle leap years
+
+This rule was added in Visual Studio 2022 17.8.
+
+## Remarks
+
+In the Gregorian calendar, every year exactly divisible by four is a leap year--except for years that are exactly divisible by 100. The centurial years are also leap years if they're exactly divisible by 400.
+
+A leap year bug occurs when software doesn't account for this leap year logic, or uses flawed logic. The can affect reliability, availability, or even the security of the affected system.
+
+Lookup tables of size 365 are often used to quickly find the month a given day corresponds to, and so on. However, it isn't correct because a leap year has 366 days.
+
+Code analysis name: `LEAP_YEAR_INVALID_DATE_KEYED_LOOKUP_MUTABLE`
+
+## Example
+
+The following code creates a lookup table for the day of the year, but assumes there are 365 days per year. However, this produces the wrong result, or can cause an out-of-bounds access of the lookup table, if the year is a leap year:
+
+```cpp
+#include
+
+void foo(int year)
+{
+ std::vector items(365); // C6394
+ // Initialize items and use it...
+ // Another item may be added to the vector if year is a leap year, but this
+ // rule doesn't check if that is the case.
+}
+```
+
+To fix this problem, adjust the size of the lookup table as the table is created according to the result of a leap year check:
+
+```cpp
+#include
+
+void foo(int year)
+{
+ bool isLeapYear = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
+ const std::vector items(isLeapYear ? 366 : 365);
+ // Initialize items and use it...
+}
+```
+
+## Heuristics
+
+This rule is enforced by checking if a lookup table has an initial size of 365 elements, but can be expanded to 366. However, it doesn't check if the table's size is adjusted through proper leap year check or not, and so is a low confidence warning.
+
+## See also
+
+[C6393](c6393.md)\
+[C26861](c26861.md)\
+[C26862](c26862.md)\
+[C26863](c26863.md)\
+[C26864](c26864.md)
diff --git a/docs/code-quality/c6395.md b/docs/code-quality/c6395.md
new file mode 100644
index 0000000000..fba3e04720
--- /dev/null
+++ b/docs/code-quality/c6395.md
@@ -0,0 +1,35 @@
+---
+title: Warning C6395
+description: "Describes the Microsoft C/C++ code analysis warning C6395, its causes, and how to address it."
+ms.date: 10/12/2023
+f1_keywords: ["C6395", "EVAL_ORDER_CHANGE"]
+helpviewer_keywords: ["C6395"]
+---
+# Warning C6395
+
+> %variable% has unsequenced reads and/or writes before C++17; changing the language standard might change the behavior of the code.
+
+## Remarks
+
+C++17 made the evaluation order of certain expressions stricter. MSVC complied, which changed the evaluation order for some expressions. Thus, changing the language version might change the observable behavior of the program. This check diagnoses some of the cases where the meaning of the code changes due to switching language versions.
+
+Code analysis name: `EVAL_ORDER_CHANGE`
+
+## Example
+
+```cpp
+void foo(int* a, int i)
+{
+ a[++i] = i; // Warning: 'i' has unsequenced reads and/or writes before C++17; changing the language standard might change the behavior of the code
+}
+```
+
+To solve this problem, separate the side effects from the rest of the expression to make the evaluation order well defined:
+
+```cpp
+void foo(int* a, int i)
+{
+ ++i;
+ a[i] = i; // No warning.
+}
+```
diff --git a/docs/code-quality/c6396.md b/docs/code-quality/c6396.md
new file mode 100644
index 0000000000..6bd3b0952b
--- /dev/null
+++ b/docs/code-quality/c6396.md
@@ -0,0 +1,34 @@
+---
+description: "Learn more about: Warning C6396: sizeof('integerConstant') always returns the size of the underlying integer type"
+title: Warning C6396
+ms.date: 02/05/2024
+f1_keywords: ["C6396", "SIZEOF_CONSTANT"]
+helpviewer_keywords: ["C6396"]
+---
+# Warning C6396
+
+> sizeof('integerConstant') always returns the size of the underlying integer type
+
+## Remarks
+
+This warning indicates where an integral constant is used as a `sizeof` argument. Such expression always returns the size of the type of the constant. It's better to write `sizeof(type)` instead. This warning catches common typos in buffer offset calculations.
+
+This check ignores character literals because `buffer_size += sizeof(UNICODE_NULL)` is a common idiom.
+
+## Example
+
+```cpp
+void f()
+{
+ int a = sizeof(5); // C6396 reported here
+}
+```
+
+To fix this issue, replace the integral constant with its type:
+
+```cpp
+void f()
+{
+ int a = sizeof(int); // no C6396 reported here
+}
+```
\ No newline at end of file
diff --git a/docs/code-quality/c6397.md b/docs/code-quality/c6397.md
new file mode 100644
index 0000000000..4247b43161
--- /dev/null
+++ b/docs/code-quality/c6397.md
@@ -0,0 +1,38 @@
+---
+description: "Learn more about: Warning C6397: The address-of operator cannot return null pointer in well-defined code"
+title: Warning C6397
+ms.date: 02/05/2024
+f1_keywords: ["C6397", "DUBIOUS_NULL_CHECK"]
+helpviewer_keywords: ["C6397"]
+---
+# Warning C6397
+
+> The address-of operator cannot return `null` pointer in well-defined code
+
+## Remarks
+
+The address-of operator returns the address of its operand. This value should never be compared to `nullptr`:
+* The address-of a field can only be `nullptr` if the base pointer was `nullptr` and the field is at the zero offset (`&p->field == nullptr` implies `p == nullptr`). In this case, the expression should be simplified.
+* In any other cases, the value of the unary `&` operator can't be `nullptr` unless there's undefined behavior in the code (`&v == nullptr` always evaluates to false).
+
+## Example
+
+```cpp
+bool isNull(int *a)
+{
+ return &a == nullptr; // C6397 reported here.
+}
+```
+
+To fix this issue, double check if the use of unary `&` was intentional:
+
+```cpp
+bool isNull(int *a)
+{
+ return a == nullptr; // no C6397 reported here.
+}
+```
+
+## See also
+
+[C6398](c6398.md)
\ No newline at end of file
diff --git a/docs/code-quality/c6398.md b/docs/code-quality/c6398.md
new file mode 100644
index 0000000000..5ee996202d
--- /dev/null
+++ b/docs/code-quality/c6398.md
@@ -0,0 +1,42 @@
+---
+description: "Learn more about: Warning C6398: The address-of a field cannot be null in well-defined code"
+title: Warning C6398
+ms.date: 02/05/2024
+f1_keywords: ["C6398", "DUBIOUS_NULL_CHECK_FIELD"]
+helpviewer_keywords: ["C6398"]
+---
+# Warning C6398
+
+> The address-of a field cannot be `null` in well-defined code
+
+## Remarks
+
+The address-of operator returns the address of its operand. This value should never be compared to `nullptr`:
+* The address-of a field can only be `nullptr` if the base pointer was `nullptr` and the field is at the zero offset (`&p->field == nullptr` implies `p == nullptr`). In this case, the expression should be simplified.
+* In any other cases, the value of the unary `&` operator can't be `nullptr` unless there's undefined behavior in the code (`&v == nullptr` always evaluates to false).
+
+## Example
+
+```cpp
+struct A { int* x; };
+
+bool hasNullField(A *a)
+{
+ return &a->x == nullptr; // C6398 reported here.
+}
+```
+
+To fix this issue, double check if the use of unary `&` was intentional:
+
+```cpp
+struct A { int* x; };
+
+bool hasNullField(A *a)
+{
+ return a->x == nullptr; // no C6398 reported here.
+}
+```
+
+## See also
+
+[C6397](c6397.md)
\ No newline at end of file
diff --git a/docs/code-quality/c6411.md b/docs/code-quality/c6411.md
index a24d5c9118..a4a99565a8 100644
--- a/docs/code-quality/c6411.md
+++ b/docs/code-quality/c6411.md
@@ -1,9 +1,9 @@
---
-description: "Learn more about: Warning C6411"
title: Warning C6411
+description: "Learn more about: Warning C6411"
ms.date: 11/04/2016
f1_keywords: ["C6411", "POTENTIAL_READ_OVERRUN"]
-ms.assetid: 6bbc1734-eec4-4ad6-9908-4ed2a5f025db
+helpviewer_keywords: ["C6411"]
---
# Warning C6411
diff --git a/docs/code-quality/c6412.md b/docs/code-quality/c6412.md
index 5c29356882..230011ec6e 100644
--- a/docs/code-quality/c6412.md
+++ b/docs/code-quality/c6412.md
@@ -1,9 +1,9 @@
---
-description: "Learn more about: Warning C6412"
title: Warning C6412
+description: "Learn more about: Warning C6412"
ms.date: 11/04/2016
f1_keywords: ["C6412", "POTENTIAL_WRITE_OVERRUN"]
-ms.assetid: 6498f045-1bdc-4428-9d95-d9498de207bb
+helpviewer_keywords: ["C6412"]
---
# Warning C6412
diff --git a/docs/code-quality/c6506.md b/docs/code-quality/c6506.md
index df143e3c84..377aef7813 100644
--- a/docs/code-quality/c6506.md
+++ b/docs/code-quality/c6506.md
@@ -1,10 +1,9 @@
---
-description: "Learn more about: Warning C6506"
title: Warning C6506
+description: "Learn more about: Warning C6506"
ms.date: 11/04/2016
f1_keywords: ["C6506", "BUFFER_SIZE_ON_NON_POINTER_OR_ARRAY", "__WARNING_BUFFER_SIZE_ON_NON_POINTER_OR_ARRAY"]
helpviewer_keywords: ["C6506"]
-ms.assetid: 20b87ee8-13ea-4d71-95a1-2b2d144d196a
---
# Warning C6506
@@ -21,7 +20,7 @@ Code analysis name: `BUFFER_SIZE_ON_NON_POINTER_OR_ARRAY`
The following code generates this warning:
```cpp
-#include
+#include
void f(_Out_ char c)
{
c = 'd';
@@ -31,7 +30,7 @@ void f(_Out_ char c)
To correct this warning, use a pointer or an array type, as shown in the following sample code:
```cpp
-#include