Skip to content

Commit 00140a3

Browse files
authored
Merge pull request #5769 from TylerMSFT/checkstack
update per behavior verified Feb 2025
2 parents bb76213 + 8852433 commit 00140a3

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs/preprocessor/check-stack.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
description: "Learn more about the check_stack pragma directive in Microsoft C/C++"
33
title: "check_stack pragma"
4-
ms.date: 01/22/2021
4+
ms.date: 2/7/2025
55
f1_keywords: ["vc-pragma.check_stack", "check_stack_CPP"]
6-
helpviewer_keywords: ["check_stack pragma", "pragma, check_stack", "pragma, check_stack usage table"]
6+
helpviewer_keywords: ["check_stack pragma", "pragma, check_stack"]
77
no-loc: ["pragma"]
88
---
99
# `check_stack` pragma
@@ -12,24 +12,24 @@ Instructs the compiler to turn off stack probes if **`off`** (or **`-`**) is spe
1212

1313
## Syntax
1414

15-
> **`#pragma check_stack(`** [{ **`on`** | **`off`** }] **`)`**\
15+
> **`#pragma check_stack(`** { **`on`** | **`off`** } **`)`**\
1616
> **`#pragma check_stack`** { **`+`** | **`-`** }
1717
1818
## Remarks
1919

20-
This pragma takes effect at the first function defined after the pragma is seen. Stack probes are neither a part of macros nor of functions that are generated inline.
20+
This pragma only applies to 32-bit platforms (x86, ARM32). It has no effect on 64-bit platforms.
2121

22-
If you don't give an argument for the **`check_stack`** pragma, stack checking reverts to the behavior specified on the command line. For more information, see [Compiler options](../build/reference/compiler-options.md). The interaction of the `#pragma check_stack` and the [`/Gs`](../build/reference/gs-control-stack-checking-calls.md) option is summarized in the following table.
22+
This pragma takes effect at the first function defined after the pragma is seen. Stack probes are not inserted for macros or functions that are generated inline.
2323

24-
### Using the check_stack Pragma
24+
`#pragma check_stack(off)` / `#pragma Check_stack-` is ignored if the size of the function locals is larger than 4096 or the value specified by `/Gs`.
2525

26-
| Syntax | Compiled with<br /><br /> `/Gs` option? | Action |
27-
|--|--|--|
28-
| `#pragma check_stack( )` or<br /><br /> `#pragma check_stack` | Yes | Turns off stack checking for functions that follow |
29-
| `#pragma check_stack( )` or<br /><br /> `#pragma check_stack` | No | Turns on stack checking for functions that follow |
30-
| `#pragma check_stack(on)`<br /><br /> or `#pragma check_stack +` | Yes or No | Turns on stack checking for functions that follow |
31-
| `#pragma check_stack(off)`<br /><br /> or `#pragma check_stack -` | Yes or No | Turns off stack checking for functions that follow |
26+
The default behavior of the compiler is to insert stack probes at the beginning of each function if the size of the locals exceeds 4096 or the value specified by `/Gs`.
27+
28+
Use [/Gs (Control stack checking calls)](../build/reference/gs-control-stack-checking-calls.md) to change the threshold of the locals that trigger stack probes. Use with caution.
29+
30+
Using `#pragma check_stack()` without arguments is deprecated.
3231

3332
## See also
3433

34+
[Compiler options](../build/reference/compiler-options.md)\
3535
[Pragma directives and the `__pragma` and `_Pragma` keywords](./pragma-directives-and-the-pragma-keyword.md)

0 commit comments

Comments
 (0)