You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/c-runtime-library/global-state.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
title: "Global state in the CRT"
3
3
description: "Describes how shared global state is handled in the Microsoft Universal C Runtime."
4
4
ms.topic: "conceptual"
5
-
ms.date: "04/02/2020"
5
+
ms.date: "10/02/2020"
6
6
helpviewer_keywords: ["CRT global state"]
7
7
---
8
8
9
9
# Global state in the CRT
10
10
11
11
Some functions in the Universal C Runtime (UCRT) use global state. For example, `setlocale()` sets the locale for the entire program, which affects the digit separators, text code page, and so on.
12
12
13
-
The UCRT's global state is not shared between applications and the OS. For example, if your application calls `setlocale()`, it won't affect the locale for any OS components that uses the C run-time, or vice-versa.
13
+
The UCRT's global state isn't shared between applications and the OS. For example, if your application calls `setlocale()`, it won't affect the locale for any OS components that uses the C run-time, or the other way around.
14
14
15
15
## OS-specific versions of CRT functions
16
16
@@ -25,8 +25,8 @@ The OS-specific versions of these functions are in `ucrt.osmode.lib`. For exampl
25
25
26
26
There are two ways to isolate your component's CRT state from an app's CRT state:
27
27
28
-
- Statically link your component by using compiler options /MT (release) or MTd (debug). For details, see [/MD, /MT, /LD](../build/reference/md-mt-ld-use-run-time-library.md). Note that static linking can greatly increase binary size.
29
-
- Starting with Windows 10 20H2, get CRT state isolation by dynamically linking to the CRT but call the OS-mode exports (the functions that begin with _o_). To call the OS-mode exports, statically link as before, but ignore the static UCRT by using linker option `/NODEFAULTLIB:libucrt.lib` (release) or `/NODEFAULTLIB:libucrtd.lib` (debug)See [/NODEFAULTLIB (Ignore Libraries)](../build/reference/nodefaultlib-ignore-libraries.md) for details. And add `ucrt.osmode.lib` to the linker input.
28
+
- Statically link your component by using compiler options `/MT` (release) or `/MTd` (debug). For details, see [/MD, /MT, /LD](../build/reference/md-mt-ld-use-run-time-library.md). Static linking can greatly increase binary size.
29
+
- Starting with Windows 10 version 2004, dynamically link to the CRT but call the OS-mode exports (the functions that begin with _o_). To call the OS-mode exports, statically link as before, but ignore the static UCRT by using linker option `/NODEFAULTLIB:libucrt.lib` (release) or `/NODEFAULTLIB:libucrtd.lib` (debug). And add `ucrt.osmode.lib` to the linker input. See [/NODEFAULTLIB (Ignore Libraries)](../build/reference/nodefaultlib-ignore-libraries.md) for details.
30
30
31
31
> [!Note]
32
32
> In source code, write `setlocale()`, not `_o_setlocale()`. When you link against `ucrt.osmode.lib`, the linker will automatically substitute the OS-specific version of the function. That is, `setlocale()` will be substituted with `_o_setlocale()`.
@@ -53,7 +53,7 @@ Global state affected by the separation of app and OS state includes:
53
53
- The buffer used by [_putch, _putwch](reference/putch-putwch.md)
0 commit comments