Skip to content

Commit a5c626c

Browse files
authored
Merge pull request MicrosoftDocs#1531 from corob-msft/cr-gs-gs0
Update for target-specific behavior, issue 445
2 parents 64384e6 + c5fe345 commit a5c626c

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

docs/build/reference/gs-control-stack-checking-calls.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "-Gs (Control Stack Checking Calls) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/25/2018"
55
ms.technology: ["cpp-tools"]
66
ms.topic: "reference"
77
f1_keywords: ["/GS"]
@@ -14,43 +14,45 @@ ms.workload: ["cplusplus"]
1414
---
1515
# /Gs (Control Stack Checking Calls)
1616

17-
Controls stack probes.
17+
Controls the threshold for stack probes.
1818

1919
## Syntax
2020

21-
```
22-
/Gs[size]
23-
```
21+
> **/Gs**[*size*]
2422
2523
## Arguments
2624

2725
*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*.
2927

3028
## Remarks
3129

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.
3331

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.
3533

3634
> [!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.
3836
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.
4038

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.
4240

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.
4448

4549
### To set this compiler option in the Visual Studio development environment
4650

4751
1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md).
4852

49-
1. Select the **C/C++** folder.
50-
51-
1. Select the **Command Line** property page.
53+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
5254

53-
1. Type the compiler option in the **Additional Options** box.
55+
1. Enter the **/Gs** compiler option and an optional size in **Additional Options**. Choose **OK** or **Apply** to save your changes.
5456

5557
### To set this compiler option programmatically
5658

0 commit comments

Comments
 (0)