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/build/reference/gs-control-stack-checking-calls.md
+18-16Lines changed: 18 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "-Gs (Control Stack Checking Calls) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "11/04/2016"
4
+
ms.date: "10/25/2018"
5
5
ms.technology: ["cpp-tools"]
6
6
ms.topic: "reference"
7
7
f1_keywords: ["/GS"]
@@ -14,43 +14,45 @@ ms.workload: ["cplusplus"]
14
14
---
15
15
# /Gs (Control Stack Checking Calls)
16
16
17
-
Controls stack probes.
17
+
Controls the threshold for stack probes.
18
18
19
19
## Syntax
20
20
21
-
```
22
-
/Gs[size]
23
-
```
21
+
> **/Gs**[*size*]
24
22
25
23
## Arguments
26
24
27
25
*size*<br/>
28
-
(Optional) The number of bytes that local variables can occupy before a stack probe is initiated. If the **/Gs**option is specified without a `size` argument, it is the same as specifying **/Gs0**,
26
+
(Optional) The number of bytes that local variables can occupy before a stack probe is initiated. No space is allowed between **/Gs**and *size*.
29
27
30
28
## Remarks
31
29
32
-
A stack probe is a sequence of code that the compiler inserts into every function call. When initiated, a stack probe reaches benignly into memory by the amount of space that is required to store the function's local variables.
30
+
A *stack probe* is a sequence of code that the compiler inserts at the beginning of a function call. When initiated, a stack probe reaches benignly into memory by the amount of space that is required to store the function's local variables. This causes the operating system to transparently page in additional stack memory if required, before the rest of the function runs.
33
31
34
-
If a function requires more than `size` bytes of stack space for local variables, its stack probe is initiated. By default, the compiler generates code that initiates a stack probe when a function requires more than one page of stack space. This is equivalent to a compiler option of **/Gs4096** for x86, x64, and ARM platforms. This value allows an application and the Windows memory manager to increase the amount of memory committed to the program stack dynamically at run time.
32
+
By default, the compiler generates code that initiates a stack probe when a function requires more than one page of stack space. This is equivalent to a compiler option of **/Gs4096** for x86, x64, ARM, and ARM64 platforms. This value allows an application and the Windows memory manager to increase the amount of memory committed to the program stack dynamically at run time.
35
33
36
34
> [!NOTE]
37
-
> The default value of **/Gs4096** allows the program stack of applications for Windows to grow correctly at run time. We recommend that you do not change the default value unless you know exactly why you have to change it.
35
+
> The default value of **/Gs4096** allows the program stack of applications for Windows to grow correctly at run time. We recommend that you do not change the default value unless you know exactly why you have to change it.
38
36
39
-
Some programs—for example, virtual device drivers—do not require this default stack-growth mechanism. In such cases, the stack probes are not necessary and you can stop the compiler from generating them by setting `size` to a value that is larger than any function will require for local variable storage. No space is allowed between **/Gs** and `size`.
37
+
Some programs—for example, virtual device drivers—do not require this default stack-growth mechanism. In such cases, the stack probes are not necessary and you can stop the compiler from generating them by setting *size* to a value that is larger than any function will require for local variable storage.
40
38
41
-
**/Gs0**activates stack probes for every function call that requires storage for local variables. This can have a negative impact on performance.
39
+
**/Gs0**initiates stack probes for every function call that requires storage for local variables. This can have a negative impact on performance.
42
40
43
-
You can turn stack probes on or off by using [check_stack](../../preprocessor/check-stack.md). **/Gs** and the `check_stack` pragma have no effect on standard C library routines; they affect only the functions you compile.
41
+
For x64 targets, if the **/Gs** option is specified without a *size* argument, it is the same as **/Gs0**. If the *size* argument is 1 through 9, warning D9014 is emitted, and the effect is the same as specifying **/Gs0**.
42
+
43
+
For x86, ARM, and ARM64 targets, the **/Gs** option without a *size* argument is the same as **/Gs4096**. If the *size* argument is 1 through 9, warning D9014 is emitted, and the effect is the same as specifying **/Gs4096**.
44
+
45
+
For all targets, a *size* argument between 10 and 2147485647 sets the threshold at the specified value. A *size* of 2147485648 or greater causes fatal error C1049.
46
+
47
+
You can turn stack probes on or off by using the [check_stack](../../preprocessor/check-stack.md) directive. **/Gs** and the `check_stack` pragma have no effect on standard C library routines; they affect only the functions you compile.
44
48
45
49
### To set this compiler option in the Visual Studio development environment
46
50
47
51
1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md).
0 commit comments